Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id$ * * Copyright (C) 2009 by Bertrik Sikken * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ****************************************************************************/ #include "config.h" #include "as3525.h" #include "dbop-as3525.h" #define DBOP_IDLE_VALUE 0xE0FF static int dbop_locked = 0; static short int dbop_input_value = DBOP_IDLE_VALUE; /* read the DBOP data pins */ static unsigned short dbop_read_input(void) { unsigned int dbop_ctrl_old = DBOP_CTRL; unsigned int dbop_timpol23_old = DBOP_TIMPOL_23; unsigned short value; /* make sure that the DBOP FIFO is empty */ while ((DBOP_STAT & (1<<10)) == 0); /* write DBOP_DOUT to pre-charge DBOP data lines with a high level */ DBOP_TIMPOL_23 = 0xe167006e; /* no strobe towards lcd */ if (dbop_locked <= 0) {/* can't write to dbop while updating */ DBOP_CTRL = (1 << 16) | /* enw=1 (enable write) */ (1 << 12); /* ow=1 (16-bit data width) */ DBOP_DOUT = DBOP_IDLE_VALUE; /* all pins high */ while ((DBOP_STAT & (1<<10)) == 0); } /* perform a DBOP read */ DBOP_CTRL = (1 << 15) | /* strd=1 (start read) */ (1 << 12) | /* ow=1 (16-bit data width) */ (31 << 0); /* rs_t=31 (read DBOP at end of cycle) */ while ((DBOP_STAT & (1<<16)) == 0); value = DBOP_DIN; /* restore previous values */ DBOP_TIMPOL_23 = dbop_timpol23_old; DBOP_CTRL = dbop_ctrl_old; if (dbop_locked > 0) { /* if we were blocked, use cached data partly */ int old_value = value; value = dbop_input_value & ~(1<<14|1<<13); value |= old_value & (1<<14|1<<13); } return value; } /* get the DBOP input value, either directly or cached if DBOP is busy */ unsigned short int dbop_input(void) { return (dbop_input_value = dbop_read_input()); } /* increase dbop lock count, if not locked yet a DBOP input sample is taken */ void dbop_lock(void) { dbop_input(); dbop_locked++; } /* decrease dbop lock count */ void dbop_unlock(void) { dbop_locked--; } |