Rev 32 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 32 | Rev 33 | ||
|---|---|---|---|
| Line 127... | Line 127... | ||
| 127 | { |
127 | { |
| 128 | // Return the received data |
128 | // Return the received data |
| 129 | return RCREG; |
129 | return RCREG; |
| 130 | } |
130 | } |
| 131 | 131 | ||
| 132 | - | ||
| 133 | /* |
- | |
| 134 | * Function: uartGets |
- | |
| 135 | * |
- | |
| 136 | * Input: Byte array to read, number of bytes to read and timeout. |
- | |
| 137 | * Output: Number of read bytes. |
- | |
| 138 | * Pre-conditions: call to uartInit() |
- | |
| 139 | * Affects: none |
- | |
| 140 | * Depends: none |
- | |
| 141 | */ |
- | |
| 142 | BYTE uartGets(BYTE *buffer, BYTE length,unsigned int uart_data_wait) |
- | |
| 143 | { |
- | |
| 144 | unsigned int wait = 0; |
- | |
| 145 | BYTE data; |
- | |
| 146 | - | ||
| 147 | while(length) |
- | |
| 148 | { |
- | |
| 149 | while(!uartDataRedy()) |
- | |
| 150 | { |
- | |
| 151 | if(wait < uart_data_wait) |
- | |
| 152 | wait++ ; /*wait for more data */ |
- | |
| 153 | else |
- | |
| 154 | return(length); /*Time out- Return words/bytes to be read */ |
- | |
| 155 | } |
- | |
| 156 | wait=0; |
- | |
| 157 | data = uartGet(); |
- | |
| 158 | *buffer = data; |
- | |
| 159 | buffer++; // Increment the string pointer |
- | |
| 160 | length--; |
- | |
| 161 | } |
- | |
| 162 | - | ||
| 163 | return(length); /* number of data yet to be received i.e.,0 */ |
- | |
| 164 | - | ||
| 165 | - | ||
| 166 | - | ||
| 167 | - | ||
| 168 | - | ||
| 169 | - | ||
| 170 | } |
- | |
| 171 | 132 | ||
| 172 | /* |
133 | /* |
| 173 | * Function: uartISR |
134 | * Function: uartISR |
| 174 | * |
135 | * |
| 175 | * Input: none |
136 | * Input: none |