Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00032 #ifndef HAL_SPI_H__
00033 #define HAL_SPI_H__
00034
00035 #include <stdint.h>
00036 #include <stdbool.h>
00037
00041 typedef enum
00042 {
00043 SPI_CLK_DIV2,
00044 SPI_CLK_DIV4,
00045 SPI_CLK_DIV8,
00046 SPI_CLK_DIV16,
00047 SPI_CLK_DIV32,
00048 SPI_CLK_DIV64,
00049 SPI_CLK_DIV128
00050 } hal_spi_clkdivider_t;
00051
00055 typedef enum {
00056 HAL_SPI_LSB_MSB,
00057 HAL_SPI_MSB_LSB
00058 } hal_spi_byte_order_t;
00059
00063 typedef enum {
00064 HAL_SPI_MODE_0,
00065 HAL_SPI_MODE_1,
00066 HAL_SPI_MODE_2,
00067 HAL_SPI_MODE_3
00068 } hal_spi_mode_t;
00069
00070
00073 void hal_spi_master_init(hal_spi_clkdivider_t ck, hal_spi_mode_t mode, hal_spi_byte_order_t bo);
00074
00082 uint8_t hal_spi_master_read_write(uint8_t pLoad);
00083
00086 void hal_spi_slave_init(hal_spi_mode_t mode, hal_spi_byte_order_t bo);
00087
00095 uint8_t hal_spi_slave_rw(uint8_t pLoad);
00096
00100 uint8_t hal_spi_slave_read(void);
00101
00105 void hal_spi_slave_preload(uint8_t pLoad);
00106
00110 bool spi_slave_data_ready(void);
00111
00112 bool hal_spi_slave_csn_high(void);
00113
00114
00115 #endif // HAL_SPI_H__
00116