Rev 136 | Rev 146 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 136 | Rev 144 | ||
---|---|---|---|
Line 118... | Line 118... | ||
118 | { |
118 | { |
119 | static u8 rxchksum = 0; |
119 | static u8 rxchksum = 0; |
120 | u8 rxdata; |
120 | u8 rxdata; |
121 | static SPI_State_t SPI_State = SPI_SYNC1; |
121 | static SPI_State_t SPI_State = SPI_SYNC1; |
Line 122... | Line 122... | ||
122 | 122 | ||
123 | // clear pending bit |
123 | // clear pending bits |
- | 124 | SSP_ClearITPendingBit(SSP0, SSP_IT_RxTimeOut); |
|
- | 125 | SSP_ClearITPendingBit(SSP0, SSP_IT_RxFifo); |
|
124 | SSP_ClearITPendingBit(SSP0, SSP_IT_RxTimeOut); |
126 | /* |
125 | // Fill TxFIFO while its not full or end of packet is reached |
127 | // Fill TxFIFO while its not full or end of packet is reached |
126 | while (SSP_GetFlagStatus(SSP0, SSP_FLAG_TxFifoNotFull) == SET) |
128 | while (SSP_GetFlagStatus(SSP0, SSP_FLAG_TxFifoNotFull) == SET) |
127 | { |
129 | { |
128 | if (SPI_TxBufferIndex < SPI_TXBUFFER_LEN) // still data to send ? |
130 | if (SPI_TxBufferIndex < SPI_TXBUFFER_LEN) // still data to send ? |
Line 139... | Line 141... | ||
139 | BeepTime = 0; // reset local beeptime |
141 | BeepTime = 0; // reset local beeptime |
140 | // copy contents of ToFlightCtrl->SPI_TxBuffer |
142 | // copy contents of ToFlightCtrl->SPI_TxBuffer |
141 | memcpy( (u8 *) &(SPI_TxBuffer[2]), (u8 *) &ToFlightCtrl, sizeof(ToFlightCtrl)); |
143 | memcpy( (u8 *) &(SPI_TxBuffer[2]), (u8 *) &ToFlightCtrl, sizeof(ToFlightCtrl)); |
142 | } |
144 | } |
143 | } |
145 | } |
- | 146 | */ |
|
144 | // while RxFIFO not empty |
147 | // while RxFIFO not empty |
145 | while (SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoNotEmpty) == SET) |
148 | while (SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoNotEmpty) == SET) |
146 | { |
149 | { |
147 | rxdata = SSP0->DR; // catch the received byte |
150 | rxdata = SSP0->DR; // catch the received byte |
148 | // Fill TxFIFO while its not full or end of packet is reached |
151 | // Fill TxFIFO while its not full or end of packet is reached |
Line 257... | Line 260... | ||
257 | SSP_InitStructure.SSP_CPOL = SSP_CPOL_Low; |
260 | SSP_InitStructure.SSP_CPOL = SSP_CPOL_Low; |
258 | SSP_InitStructure.SSP_ClockRate = 0; |
261 | SSP_InitStructure.SSP_ClockRate = 0; |
Line 259... | Line 262... | ||
259 | 262 | ||
Line 260... | Line 263... | ||
260 | SSP_Init(SSP0, &SSP_InitStructure); |
263 | SSP_Init(SSP0, &SSP_InitStructure); |
- | 264 | ||
- | 265 | //SSP_ITConfig(SSP0, SSP_IT_RxFifo | SSP_IT_TxFifo | SSP_IT_RxTimeOut, ENABLE); |
|
Line 261... | Line 266... | ||
261 | 266 | SSP_ITConfig(SSP0, SSP_IT_RxFifo | SSP_IT_RxTimeOut, ENABLE); |
|
Line 262... | Line 267... | ||
262 | SSP_ITConfig(SSP0, SSP_IT_RxFifo | SSP_IT_TxFifo | SSP_IT_RxTimeOut, ENABLE); |
267 | |
263 | 268 |