|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
#include "board_spi.h"#include <string.h>#include "board.h"#include "cmsis_os2.h"#include "main.h"Go to the source code of this file.
Classes | |
| struct | board_spi_route_t |
Functions | |
| static int | bus_index (const SPI_HandleTypeDef *spi) |
| static const board_spi_route_t * | route (board_spi_device_t device) |
| bool | board_spi_init (void) |
| bool | board_spi_routed (board_spi_device_t device) |
| uint8_t | board_spi_mode (board_spi_device_t device) |
| uint32_t | board_spi_clock_hz (board_spi_device_t device) |
| board_spi_status_t | board_spi_lock (board_spi_device_t device, uint32_t deadline_ms) |
| void | board_spi_unlock (board_spi_device_t device) |
| static board_spi_status_t | wait_busy_low (const board_spi_route_t *r, uint32_t deadline_ms) |
| static board_spi_status_t | shift (const board_spi_route_t *r, const uint8_t *tx, uint8_t *rx, uint16_t len, uint32_t deadline_ms) |
| board_spi_status_t | board_spi_frame (board_spi_device_t device, const uint8_t *tx, uint8_t *rx, uint16_t len, uint32_t deadline_ms) |
| board_spi_status_t | board_spi_transfer (board_spi_device_t device, const uint8_t *tx, uint8_t *rx, uint16_t len, uint32_t deadline_ms) |
| void | board_spi_select (board_spi_device_t device) |
| void | board_spi_deselect (board_spi_device_t device) |
| board_spi_status_t | board_spi_shift (board_spi_device_t device, const uint8_t *tx, uint8_t *rx, uint16_t len, uint32_t deadline_ms) |
| board_spi_status_t | board_spi_idle_clocks (board_spi_device_t device, uint16_t len, uint32_t deadline_ms) |
| static board_spi_device_t | from_self_test (uint16_t device_id) |
| static self_test_reply_t | st_reply (self_test_result_t result, int32_t diag) |
| self_test_reply_t | board_spi_self_test_exchange (void *context, uint16_t device_id, uint8_t mode, uint32_t max_hz, self_test_spi_frame_t *frames, uint8_t count, uint32_t budget_ms) |
Variables | |
| SPI_HandleTypeDef | hspi1 |
| SPI_HandleTypeDef | hspi2 |
| SPI_HandleTypeDef | hspi3 |
| SPI_HandleTypeDef | hspi4 |
| static const board_spi_route_t | routes [BOARD_SPI_COUNT] |
| static osMutexId_t | bus_locks [4] |
| uint32_t board_spi_clock_hz | ( | board_spi_device_t | device | ) |
Definition at line 82 of file board_spi.c.
References HAL_RCCEx_GetPeriphCLKFreq(), hspi4, r, RCC_PERIPHCLK_SPI123, RCC_PERIPHCLK_SPI45, route(), SPI_CFG1_MBR, and SPI_CFG1_MBR_Pos.
Referenced by board_spi_self_test_exchange().
| void board_spi_deselect | ( | board_spi_device_t | device | ) |
Definition at line 195 of file board_spi.c.
References GPIO_PIN_SET, HAL_GPIO_WritePin(), r, and route().
Referenced by ms5611_reset(), sd_command(), and sd_read_cid().
| board_spi_status_t board_spi_frame | ( | board_spi_device_t | device, |
| const uint8_t * | tx, | ||
| uint8_t * | rx, | ||
| uint16_t | len, | ||
| uint32_t | deadline_ms ) |
Definition at line 163 of file board_spi.c.
References BOARD_SPI_NOT_CONFIGURED, BOARD_SPI_OK, GPIO_PIN_RESET, GPIO_PIN_SET, HAL_GPIO_WritePin(), r, route(), shift(), and wait_busy_low().
Referenced by board_spi_self_test_exchange(), and board_spi_transfer().
| board_spi_status_t board_spi_idle_clocks | ( | board_spi_device_t | device, |
| uint16_t | len, | ||
| uint32_t | deadline_ms ) |
Definition at line 210 of file board_spi.c.
References BOARD_SPI_NOT_CONFIGURED, GPIO_PIN_SET, HAL_GPIO_WritePin(), NULL, r, route(), and shift().
Referenced by sd_nand_probe().
| bool board_spi_init | ( | void | ) |
Definition at line 56 of file board_spi.c.
References bus_locks, NULL, osMutexNew(), and osMutexPrioInherit.
Referenced by board_bringup_power_up().
| board_spi_status_t board_spi_lock | ( | board_spi_device_t | device, |
| uint32_t | deadline_ms ) |
Definition at line 94 of file board_spi.c.
References board_ms_left(), BOARD_SPI_NOT_CONFIGURED, BOARD_SPI_OK, BOARD_SPI_TIMEOUT, bus_index(), bus_locks, lock, osMutexAcquire(), osOK, r, and route().
Referenced by board_spi_self_test_exchange(), board_spi_transfer(), ms5611_reset(), and sd_nand_probe().
| uint8_t board_spi_mode | ( | board_spi_device_t | device | ) |
Definition at line 73 of file board_spi.c.
References r, route(), SPI_PHASE_2EDGE, and SPI_POLARITY_HIGH.
Referenced by board_spi_self_test_exchange().
| bool board_spi_routed | ( | board_spi_device_t | device | ) |
Definition at line 69 of file board_spi.c.
References route().
Referenced by board_spi_self_test_exchange().
| void board_spi_select | ( | board_spi_device_t | device | ) |
Definition at line 189 of file board_spi.c.
References GPIO_PIN_RESET, HAL_GPIO_WritePin(), r, and route().
Referenced by ms5611_reset(), sd_command(), and sd_read_cid().
| self_test_reply_t board_spi_self_test_exchange | ( | void * | context, |
| uint16_t | device_id, | ||
| uint8_t | mode, | ||
| uint32_t | max_hz, | ||
| self_test_spi_frame_t * | frames, | ||
| uint8_t | count, | ||
| uint32_t | budget_ms ) |
Definition at line 243 of file board_spi.c.
References board_now_ms(), board_spi_clock_hz(), board_spi_frame(), board_spi_lock(), board_spi_mode(), BOARD_SPI_NOT_CONFIGURED, BOARD_SPI_OK, board_spi_routed(), BOARD_SPI_TIMEOUT, board_spi_unlock(), count(), from_self_test(), SELF_TEST_FAIL, SELF_TEST_NOT_CONFIGURED, SELF_TEST_PASS, SELF_TEST_TIMEOUT, and st_reply().
Referenced by board_bringup_power_up().
| board_spi_status_t board_spi_shift | ( | board_spi_device_t | device, |
| const uint8_t * | tx, | ||
| uint8_t * | rx, | ||
| uint16_t | len, | ||
| uint32_t | deadline_ms ) |
Definition at line 201 of file board_spi.c.
References BOARD_SPI_NOT_CONFIGURED, r, route(), and shift().
Referenced by ms5611_reset(), sd_command(), and sd_read_cid().
| board_spi_status_t board_spi_transfer | ( | board_spi_device_t | device, |
| const uint8_t * | tx, | ||
| uint8_t * | rx, | ||
| uint16_t | len, | ||
| uint32_t | deadline_ms ) |
Definition at line 178 of file board_spi.c.
References board_spi_frame(), board_spi_lock(), BOARD_SPI_OK, and board_spi_unlock().
Referenced by anonymous_namespace{radio_task.cpp}::BoardBus::transfer(), and xfer().
| void board_spi_unlock | ( | board_spi_device_t | device | ) |
Definition at line 108 of file board_spi.c.
References bus_index(), bus_locks, osMutexRelease(), r, and route().
Referenced by board_spi_self_test_exchange(), board_spi_transfer(), ms5611_reset(), and sd_nand_probe().
|
static |
Definition at line 37 of file board_spi.c.
References hspi1, hspi2, hspi3, and hspi4.
Referenced by board_spi_lock(), and board_spi_unlock().
|
static |
Definition at line 221 of file board_spi.c.
References BOARD_SPI_BARO, BOARD_SPI_COUNT, BOARD_SPI_ETH, BOARD_SPI_HIGH_G, BOARD_SPI_IMU, BOARD_SPI_RADIO, SELF_TEST_DEVICE_BAROMETER, SELF_TEST_DEVICE_ETHERNET, SELF_TEST_DEVICE_HIGH_G, SELF_TEST_DEVICE_IMU, and SELF_TEST_DEVICE_RADIO.
Referenced by board_spi_self_test_exchange().
|
static |
Definition at line 49 of file board_spi.c.
References BOARD_SPI_COUNT, NULL, and routes.
Referenced by board_spi_clock_hz(), board_spi_deselect(), board_spi_frame(), board_spi_idle_clocks(), board_spi_lock(), board_spi_mode(), board_spi_routed(), board_spi_select(), board_spi_shift(), board_spi_unlock(), and QwDevISM330DHCX::configureWakeUpOnInt1().
|
static |
Definition at line 128 of file board_spi.c.
References board_ms_left(), BOARD_SPI_ERROR, BOARD_SPI_OK, BOARD_SPI_TIMEOUT, HAL_OK, HAL_SPI_TransmitReceive(), HAL_TIMEOUT, r, and sink().
Referenced by board_spi_frame(), board_spi_idle_clocks(), and board_spi_shift().
|
static |
Definition at line 238 of file board_spi.c.
Referenced by board_spi_self_test_exchange().
|
static |
Definition at line 115 of file board_spi.c.
References board_deadline_passed(), BOARD_SPI_OK, BOARD_SPI_TIMEOUT, GPIO_PIN_SET, HAL_GPIO_ReadPin(), and r.
Referenced by board_spi_frame().
|
static |
Definition at line 35 of file board_spi.c.
Referenced by board_spi_init(), board_spi_lock(), and board_spi_unlock().
|
extern |
Definition at line 56 of file main.c.
Referenced by bus_index(), and MX_SPI1_Init().
|
extern |
Definition at line 57 of file main.c.
Referenced by bus_index(), and MX_SPI2_Init().
|
extern |
Definition at line 58 of file main.c.
Referenced by bus_index(), and MX_SPI3_Init().
|
extern |
Definition at line 59 of file main.c.
Referenced by board_spi_clock_hz(), bus_index(), and MX_SPI4_Init().
|
static |
Definition at line 24 of file board_spi.c.