![]() |
HT32SX Monarch Scan
Monarch Scan application for HT32SX
|
: This file provides code for the configuration of the SPI instances. More...
#include "spi.h"Macros | |
| #define | HEADER_WRITE_MASK 0x00 |
| #define | HEADER_READ_MASK 0x01 |
| #define | HEADER_ADDRESS_MASK 0x00 |
| #define | HEADER_COMMAND_MASK 0x80 |
| #define | LINEAR_FIFO_ADDRESS 0xFF |
| #define | BUILT_HEADER(add_comm, w_r) (add_comm | w_r) |
| #define | WRITE_HEADER BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_WRITE_MASK) |
| #define | READ_HEADER BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_READ_MASK) |
| #define | COMMAND_HEADER BUILT_HEADER(HEADER_COMMAND_MASK, HEADER_WRITE_MASK) |
| #define | SPI_ENTER_CRITICAL() __disable_irq() |
| #define | SPI_EXIT_CRITICAL() __enable_irq() |
| #define | SdkEvalSPICSLow() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET) |
| #define | SdkEvalSPICSHigh() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET) |
| #define | WAIT_FOR_SPI_TC() |
Functions | |
| void | MX_SPI1_Init (void) |
| void | HAL_SPI_MspInit (SPI_HandleTypeDef *spiHandle) |
| void | HAL_SPI_MspDeInit (SPI_HandleTypeDef *spiHandle) |
| uint16_t | S2LPSpiReadRegisters (uint8_t address, uint8_t n_bytes, uint8_t *buffer) |
| SPI function to read registers from a slave device. More... | |
| uint16_t | S2LPSpiWriteRegisters (uint8_t address, uint8_t n_bytes, uint8_t *buffer) |
| SPI function to write registers of a slave device. More... | |
| uint16_t | S2LPSpiCommandStrobes (uint8_t command) |
| uint16_t | S2LPSpiReadFifo (uint8_t n_bytes, uint8_t *buffer) |
| uint16_t | S2LPSpiWriteFifo (uint8_t n_bytes, uint8_t *buffer) |
| __weak void | SdkEvalSpiRawTC (void) |
| void | S2LPSpiRaw (uint8_t n_bytes, uint8_t *in_buffer, uint8_t *out_buffer, uint8_t can_return_bef_tx) |
| void | HAL_SPI_TxRxCpltCallback (SPI_HandleTypeDef *hspi) |
| void | ST_MCU_API_SpiRaw (uint8_t n_bytes, uint8_t *in_buffer, uint8_t *out_buffer, uint8_t can_return_bef_tx) |
| void | S2LPSetSpiInUse (uint8_t state) |
| Set the S2LP in use flag. More... | |
| uint8_t | S2LPGetSpiInUse (void) |
| Get the S2LP in use flag. More... | |
Variables | |
| SPI_HandleTypeDef | hspi1 |
| DMA_HandleTypeDef | hdma_spi1_tx |
| DMA_HandleTypeDef | hdma_spi1_rx |
: This file provides code for the configuration of the SPI instances.
This software component is licensed by ST under BSD 3-Clause license, the "License"; You may not use this file except in compliance with the License. You may obtain a copy of the License at: opensource.org/licenses/BSD-3-Clause
| #define BUILT_HEADER | ( | add_comm, | |
| w_r | |||
| ) | (add_comm | w_r) |
macro to build the header byte
| #define COMMAND_HEADER BUILT_HEADER(HEADER_COMMAND_MASK, HEADER_WRITE_MASK) |
macro to build the command header byte
| #define HEADER_ADDRESS_MASK 0x00 |
Address mask for header byte
| #define HEADER_COMMAND_MASK 0x80 |
Command mask for header byte
| #define HEADER_READ_MASK 0x01 |
Read mask for header byte
| #define HEADER_WRITE_MASK 0x00 |
Write mask for header byte
| #define LINEAR_FIFO_ADDRESS 0xFF |
Linear FIFO address
| #define READ_HEADER BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_READ_MASK) |
macro to build the read header byte
| #define WAIT_FOR_SPI_TC | ( | ) |
| #define WRITE_HEADER BUILT_HEADER(HEADER_ADDRESS_MASK, HEADER_WRITE_MASK) |
macro to build the write header byte
| void HAL_SPI_MspDeInit | ( | SPI_HandleTypeDef * | spiHandle | ) |
SPI1 GPIO Configuration
PB4 ---—> SPI1_MISO PB3 ---—> SPI1_SCK PA7 ---—> SPI1_MOSI
| void HAL_SPI_MspInit | ( | SPI_HandleTypeDef * | spiHandle | ) |
SPI1 GPIO Configuration
PB4 ---—> SPI1_MISO PB3 ---—> SPI1_SCK PA7 ---—> SPI1_MOSI
| uint8_t S2LPGetSpiInUse | ( | void | ) |
Get the S2LP in use flag.
| [in] | none | |
| [out] | none |
| spi_in_use | 1 if in use, else 0 |
| void S2LPSetSpiInUse | ( | uint8_t | state | ) |
Set the S2LP in use flag.
| [in] | state | 1 if in use, else 0 |
| [out] | none |
| none |
| uint16_t S2LPSpiReadRegisters | ( | uint8_t | RegisterAddr, |
| uint8_t | NumByteToRead, | ||
| uint8_t * | pBuffer | ||
| ) |
SPI function to read registers from a slave device.
| RegisterAddr | register address |
| NumByteToRead | number of byte to read |
| pBuffer | buffer to retrieve data from a slave |
| ErrorStatus | error status ErrorStatus This parameter can be: SUCCESS or ERROR. |
| uint16_t S2LPSpiWriteRegisters | ( | uint8_t | address, |
| uint8_t | n_bytes, | ||
| uint8_t * | buffer | ||
| ) |
SPI function to write registers of a slave device.
| RegisterAddr | register address |
| NumByteToRead | number of byte to write |
| pBuffer | buffer contains data to write |
| ErrorStatus | error status ErrorStatus This parameter can be: SUCCESS or ERROR. |