
BLE Nano Code.Tested with Integrated mDot code
Dependencies: BLE_API mbed nRF51822
Fork of eco_Labs_ble_Client by
Diff: spi_slave.cpp
- Revision:
- 15:67fbed00edf2
- Parent:
- 12:c7a8a7fe76fd
- Child:
- 16:79b149aae10a
--- a/spi_slave.cpp Fri Oct 07 10:10:17 2016 +0000 +++ b/spi_slave.cpp Tue Oct 11 09:49:14 2016 +0000 @@ -12,7 +12,7 @@ * ****************************************************************************** */ - + /******************************************************************************/ /* Include Files*/ /******************************************************************************/ @@ -20,22 +20,22 @@ #include "spi_slave.h" #include "ble_types.h" #include "ble_msg_handler.h" - - + + /******************************************************************************/ /* Local Defines */ /******************************************************************************/ #define SPI_DUMMY_BYTE 0x00 - + #define SPI_TX_BUF_SIZE 64 #define SPI_TX_EMPTY_DATA 0xFF - + /******************************************************************************/ /* Extern Variable/functions */ /******************************************************************************/ extern bool toggle_led_flag; extern void spi_rx_Data_Callback(uint8_t *rx_data, uint8_t len); - + /******************************************************************************/ /* Static Variables */ /******************************************************************************/ @@ -43,13 +43,13 @@ SPISlave device(P0_9, P0_11,P0_8, P0_10); // mosi, miso, sclk, ssel DigitalOut spi_rqst(P0_28); DigitalOut spi_rdy(P0_29); - + static spi_data_ready_callback_t spi_data_ready_cb; - + uint8_t spi_tx_buf[SPI_TX_BUF_SIZE]; uint8_t spi_tx_ptr; uint8_t spi_bytes_to_send; - + /******************************************************************************/ /* Global Functions */ /******************************************************************************/ @@ -83,7 +83,7 @@ spi_bytes_to_send = 0; memset(spi_tx_buf, SPI_TX_EMPTY_DATA, SPI_TX_BUF_SIZE); } - + /** * @brief Receive data from Master * @param @@ -105,9 +105,10 @@ if (spi_bytes_to_send > 0) { //device.reply(rx_buf[byte_cnt]); device.reply(spi_tx_buf[send_ptr++]); - if (spi_tx_ptr++ > SPI_TX_BUF_SIZE) { - spi_tx_ptr= 0; - } + // if (spi_tx_ptr++ > SPI_TX_BUF_SIZE) { + // spi_tx_ptr= 0; + // } + // send_ptr++; spi_bytes_to_send--; if(spi_bytes_to_send ==0) { @@ -127,7 +128,7 @@ } } } - + /** * @brief Send data to Master * @param @@ -150,7 +151,7 @@ } } - + /** * @brief Function used to register spi data receive callback * @param none @@ -160,15 +161,15 @@ { spi_data_ready_cb = data_rx_callback; } - - + + void init_interrupt_line(void ) { spi_rqst =0; spi_rdy =0; } - - + + /******************************************************************************/ /* END OF FILE */ -/******************************************************************************/ +/******************************************************************************/ \ No newline at end of file