| | |
| | | int writetospi |
| | | ( |
| | | uint16_t headerLength, |
| | | uint8_t *headerBuffer, |
| | | uint8_t *headerBuffer, |
| | | uint32_t bodylength, |
| | | uint8_t *bodyBuffer |
| | | uint8_t *bodyBuffer |
| | | ) |
| | | { |
| | | |
| | |
| | | // delay_ms(1); |
| | | for(i = 0; i < headerLength; i++) |
| | | { |
| | | SPIx->DR= headerBuffer[i]; |
| | | while ((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); |
| | | SPIx->DR= headerBuffer[i]; |
| | | while ((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); |
| | | SPIx->DR; |
| | | |
| | | } |
| | |
| | | for(i = 0; i < bodylength; i++) |
| | | { |
| | | SPIx->DR = bodyBuffer[i]; |
| | | while ((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); |
| | | while ((SPIx->SR & SPI_FLAG_RXNE) == (uint16_t)RESET); |
| | | SPIx->DR ; |
| | | } |
| | | |
| | | SPIx_CS_GPIO->BSRR = SPIx_CS; |
| | | |
| | | // decamutexoff(stat) ; |
| | | // decamutexoff(stat) ; |
| | | |
| | | return 0; |
| | | } // end writetospi() |
| | |
| | | int readfromspi |
| | | ( |
| | | uint16_t headerLength, |
| | | uint8_t *headerBuffer, |
| | | uint8_t *headerBuffer, |
| | | uint32_t readlength, |
| | | uint8_t *readBuffer |
| | | ) |
| | |
| | | |
| | | decaIrqStatus_t stat ; |
| | | |
| | | // stat = decamutexon() ; |
| | | // stat = decamutexon() ; |
| | | |
| | | /* Wait for SPIx Tx buffer empty */ |
| | | //while (port_SPIx_busy_sending()); |
| | |
| | | |
| | | SPIx_CS_GPIO->BSRR = SPIx_CS; |
| | | |
| | | // decamutexoff(stat) ; |
| | | // decamutexoff(stat) ; |
| | | |
| | | return 0; |
| | | } // end readfromspi() |