Bosch XDK110 Getting Started page 18

Cross-domain development kit
Hide thumbs Also See for XDK110:
Table of Contents

Advertisement

Extension Bus Advanced Guide | XDK110
Code 18. SPI event callback function
void
SpiAppCallback(SPI_T
BCDS_UNUSED(spi);
if
((event.TxComplete) || (event.RxComplete)){
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
if
(xSemaphoreGiveFromISR(spiCompleteSync, &xHigherPriorityTaskWoken) == pdTRUE){
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
}
The code adds control logic to the triggered events, when a SPI data frame is transmitted or received via the SPI module. A
semaphore is inserted for controlled receiving and transmitting of data. After the semaphore
new data can be transmitted or received. This will be further explained and cleared up in the context of code 23.
Afterwards, the SPI module on driver level can be initialized. Code 19 shows how to proceed with that.
Code 19. Initializing the SPI module
SpiHandle = BSP_ExtensionPort_GetSpiHandle();
MCU_SPI_Initialize(SpiHandle, SpiAppCallback);
BSP_ExtensionPort_GetSpiHandle()
First, the function
BSP_ExtensionPort.h interface in the global variable
Code 18 is passed into the function
Now, the SPI module itself is configured, including the MISO, MOSI and Clock line. Only the CS line is left to be configured.
For that, configuration applied to the Extension Bus pin PB8 needs to be done. Code 20 shows a outline on how to proceed
with that.
Code 20. Configuring the chip select line
BSP_ExtensionPort_ConnectGpio(BSP_EXTENSIONPORT_GPIO_PD8);
BSP_ExtensionPort_SetGpioConfig(BSP_EXTENSIONPORT_GPIO_PD8, BSP_EXTENSIONPORT_GPIO_PINMODE,
(uint32_t) BSP_EXTENSIONPORT_PUSHPULL, NULL);
BSP_ExtensionPort_EnableGpio(BSP_EXTENSIONPORT_GPIO_PD8);
spi, struct
MCU_SPI_Event_S
SpiHandle
MCU_SPI_Initialize()
to initialize the SPI module.
event){
is used to store all configurations made with the
. Then this variable and the callback function, declared in
18 24
spiCompleteSync
is released,
|

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents