Rev 360 | Rev 369 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 360 | Rev 362 | ||
---|---|---|---|
Line 53... | Line 53... | ||
53 | // + #### END OF LICENSING TERMS #### |
53 | // + #### END OF LICENSING TERMS #### |
54 | // + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de. |
54 | // + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de. |
55 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
55 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56 | #include "91x_lib.h" |
56 | #include "91x_lib.h" |
57 | #include "config.h" |
57 | #include "config.h" |
- | 58 | #include "main.h" |
|
Line 58... | Line 59... | ||
58 | 59 | ||
59 | //________________________________________________________________________________________________________________________________________ |
60 | //________________________________________________________________________________________________________________________________________ |
60 | // Module name: ssc.c |
61 | // Module name: ssc.c |
61 | // Compiler used: avr-gcc 3.4.5 |
62 | // Compiler used: avr-gcc 3.4.5 |
Line 244... | Line 245... | ||
244 | //________________________________________________________________________________________________________________________________________ |
245 | //________________________________________________________________________________________________________________________________________ |
Line 245... | Line 246... | ||
245 | 246 | ||
246 | u8 SSC_GetChar (void) |
247 | u8 SSC_GetChar (void) |
247 | { |
248 | { |
248 | u8 Byte = 0; |
249 | u8 Byte = 0; |
249 | while(SSP_GetFlagStatus(SSP1, SSP_FLAG_TxFifoNotFull) != SET); // wait for space in the tx fifo |
250 | while(SSP_GetFlagStatus(SSP1, SSP_FLAG_TxFifoNotFull) != SET && (SD_WatchDog)); // wait for space in the tx fifo |
250 | SSP_SendData(SSP1, 0xFF);// send dymmy byte (0xFF) as master to receive a byte from the slave |
251 | SSP_SendData(SSP1, 0xFF);// send dymmy byte (0xFF) as master to receive a byte from the slave |
251 | while(SSP_GetFlagStatus(SSP1, SSP_FLAG_TxFifoEmpty) != SET); // wait for the byte to be sent |
252 | while(SSP_GetFlagStatus(SSP1, SSP_FLAG_TxFifoEmpty) != SET && (SD_WatchDog)); // wait for the byte to be sent |
252 | Byte = SSP_ReceiveData(SSP1); // read the byte transmitted from the slave |
253 | Byte = SSP_ReceiveData(SSP1); // read the byte transmitted from the slave |
253 | return (Byte); |
254 | return (Byte); |
Line 254... | Line 255... | ||
254 | } |
255 | } |
255 | 256 | ||
256 | //________________________________________________________________________________________________________________________________________ |
257 | //________________________________________________________________________________________________________________________________________ |
257 | void SSC_ClearRxFifo (void) |
258 | void SSC_ClearRxFifo (void) |
258 | { |
259 | { |
259 | // wait that the tx fifo is empty |
260 | // wait that the tx fifo is empty |
260 | while(SSP_GetFlagStatus(SSP1, SSP_FLAG_TxFifoEmpty) != SET); |
261 | while(SSP_GetFlagStatus(SSP1, SSP_FLAG_TxFifoEmpty) != SET && (SD_WatchDog)); |
261 | // then empty the rx fifo by reading all the bytes that are available |
262 | // then empty the rx fifo by reading all the bytes that are available |
262 | while(SSP_GetFlagStatus(SSP1, SSP_FLAG_RxFifoNotEmpty) == SET) SSP_ReceiveData(SSP1); |
263 | while(SSP_GetFlagStatus(SSP1, SSP_FLAG_RxFifoNotEmpty) == SET && (SD_WatchDog)) SSP_ReceiveData(SSP1); |
263 | } |
264 | } |
264 | //________________________________________________________________________________________________________________________________________ |
265 | //________________________________________________________________________________________________________________________________________ |
265 | // Function: SSC_PutChar(u8 Byte); |
266 | // Function: SSC_PutChar(u8 Byte); |
Line 271... | Line 272... | ||
271 | //________________________________________________________________________________________________________________________________________ |
272 | //________________________________________________________________________________________________________________________________________ |
Line 272... | Line 273... | ||
272 | 273 | ||
273 | void SSC_PutChar (u8 Byte) |
274 | void SSC_PutChar (u8 Byte) |
274 | { |
275 | { |
275 | // wait for some space in the tx fifo |
276 | // wait for some space in the tx fifo |
276 | while(SSP_GetFlagStatus(SSP1, SSP_FLAG_TxFifoNotFull) != SET); |
277 | while(SSP_GetFlagStatus(SSP1, SSP_FLAG_TxFifoNotFull) != SET && (SD_WatchDog)); |
277 | // put the byte to send in the tx fifo |
278 | // put the byte to send in the tx fifo |
278 | SSP_SendData(SSP1, Byte); |
279 | SSP_SendData(SSP1, Byte); |