Sensor/Actuator I2C & SPI interface functions, used by Baremetal Sensor/Actuator interface.
More...
|
| enum | sensorif_i2c_status {
SENSORIF_I2C_ST_START = 0x08
, SENSORIF_I2C_ST_RSTART = 0x10
, SENSORIF_I2C_ST_TX_AD_ACK = 0x18
, SENSORIF_I2C_ST_TX_AD_NACK = 0x20
,
SENSORIF_I2C_ST_TX_DT_ACK = 0x28
, SENSORIF_I2C_ST_TX_DT_NACK = 0x30
, SENSORIF_I2C_ST_ARB_LOST = 0x38
, SENSORIF_I2C_ST_RX_AD_ACK = 0x40
,
SENSORIF_I2C_ST_RX_AD_NACK = 0x48
, SENSORIF_I2C_ST_RX_DT_ACK = 0x50
, SENSORIF_I2C_ST_RX_DT_NACK = 0x58
, SENSORIF_I2C_ST_BUS_ERROR_RAW = 0x00
,
SENSORIF_I2C_ST_STOP = 0xF0
, SENSORIF_I2C_ST_RELEASED = 0xF8
, SENSORIF_I2C_ST_NOT_IMPLEMENTED = 0xFE
, SENSORIF_I2C_ST_SUCCESS = 0x00
,
SENSORIF_I2C_ST_TIMEOUT = 0xFF
, SENSORIF_I2C_ST_BUS_ERROR = 0xF1
} |
| | I2C master status enumerations. More...
|
| |
| enum | PWM_type_t { NOT_INITIALISED = 0
, USING_BPWM = 1
, USING_EPWM = 2
} |
| |
|
| void | SENSORIF_I2C_Init (void) |
| | Initialises and enables I2C interface.
|
| |
| void | SENSORIF_I2C_Deinit (void) |
| | Disables I2C interface.
|
| |
| enum sensorif_i2c_status | SENSORIF_I2C_Write (u8_t slaveaddr, u8_t *data, u32_t *len) |
| | Writes bytes to I2C slave.
|
| |
| enum sensorif_i2c_status | SENSORIF_I2C_Read (u8_t slaveaddr, u8_t *pdata, u32_t *plen) |
| | Reads bytes from I2C slave.
|
| |
| void | SENSORIF_SPI_Init (bool is_eink_display_present) |
| | Initialises and enables SPI interface.
|
| |
| void | SENSORIF_SPI_Deinit (void) |
| | Disables SPI interface.
|
| |
| ca_error | SENSORIF_SPI_Write (u8_t out_data) |
| | Writes bytes to SPI slave.
|
| |
| void | SENSORIF_SPI_FULL_DUPLEX_RXONLY (u8_t *RxBuf, u8_t RxLen) |
| | Read data in the RX while sending IDLE data to TX.
|
| |
| void | SENSORIF_SPI_WRITE_THEN_READ (u8_t *RxBuf, u8_t *TxBuf, u8_t RxLen, u8_t TxLen) |
| | Exchange bytes between SPI slave and master.
|
| |
| void | SENSORIF_UART_Init (void) |
| | Initialises and enables UART interface.
|
| |
| void | SENSORIF_UART_Deinit (void) |
| | Disables UART interface.
|
| |
| u32_t | SENSORIF_UART_Write (u8_t *out_data, u32_t writebytes) |
| | Writes bytes to UART slave.
|
| |
| u32_t | SENSORIF_UART_Read (u8_t *in_data, u32_t readbytes) |
| | Read bytes to UART slave.
|
| |
| void | SENSORIF_I2C_Config (u32_t portnum) |
| | Set I2C Configuration.
|
| |
| void | SENSORIF_SPI_Config (u32_t portnum) |
| | Set SPI Configuration.
|
| |
| void | SENSORIF_UART_Config (u32_t portnum) |
| | Set UART Configuration.
|
| |
| ca_error | SENSORIF_PWM_Init (u8_t pin, u32_t u32Frequency, u32_t u32DutyCycle) |
| | Initialises and enables PWM for the specified frequency and duty cycle.
|
| |
| void | SENSORIF_PWM_Deinit (void) |
| | Deinitialises and disables PWM.
|
| |
| void | SENSORIF_PWM_SetDutyCycle (u32_t u32DutyCycle) |
| | Changes the duty cycle of the PWM.
|
| |
Sensor/Actuator I2C & SPI interface functions, used by Baremetal Sensor/Actuator interface.
◆ SENSORIF_I2C_CLK_FREQUENCY
| #define SENSORIF_I2C_CLK_FREQUENCY 100000 /* I2C SCL frequency [Hz], 100kHz (full-speed) */ |
◆ SENSORIF_I2C_TIMEOUT
| #define SENSORIF_I2C_TIMEOUT 100 /* I2C bus access time-out time in [ms] */ |
◆ SENSORIF_INT_PULLUPS
| #define SENSORIF_INT_PULLUPS 0 /* I2C use internal pull-ups flag */ |
◆ SENSORIF_SPI_CLK_FREQUENCY
| #define SENSORIF_SPI_CLK_FREQUENCY 4000000 /* SPI CLK frequency [Hz], 4MHz (max frequency for E-paper display) */ |
◆ SENSORIF_SPI_DATA_WIDTH
| #define SENSORIF_SPI_DATA_WIDTH 8 |
◆ UART_SENSORIF_BAUDRATE
| #define UART_SENSORIF_BAUDRATE 115200 |
◆ PWM_type_t
| Enumerator |
|---|
| NOT_INITIALISED | |
| USING_BPWM | |
| USING_EPWM | |
◆ sensorif_i2c_status
I2C master status enumerations.
| Enumerator |
|---|
| SENSORIF_I2C_ST_START | start
|
| SENSORIF_I2C_ST_RSTART | repeat start
|
| SENSORIF_I2C_ST_TX_AD_ACK | transmit address ACKed
|
| SENSORIF_I2C_ST_TX_AD_NACK | transmit address NACKed
|
| SENSORIF_I2C_ST_TX_DT_ACK | transmit data ACKed
|
| SENSORIF_I2C_ST_TX_DT_NACK | transmit data NACKed
|
| SENSORIF_I2C_ST_ARB_LOST | arbitration lost
|
| SENSORIF_I2C_ST_RX_AD_ACK | receive address ACKed
|
| SENSORIF_I2C_ST_RX_AD_NACK | receive address NACKed
|
| SENSORIF_I2C_ST_RX_DT_ACK | receive data ACKed
|
| SENSORIF_I2C_ST_RX_DT_NACK | receive data NACKed
|
| SENSORIF_I2C_ST_BUS_ERROR_RAW | bus error code transmitted over wire
|
| SENSORIF_I2C_ST_STOP | on reset or stop
|
| SENSORIF_I2C_ST_RELEASED | bus released
|
| SENSORIF_I2C_ST_NOT_IMPLEMENTED | not implemented
|
| SENSORIF_I2C_ST_SUCCESS | successful transfer
|
| SENSORIF_I2C_ST_TIMEOUT | bus access time-out
|
| SENSORIF_I2C_ST_BUS_ERROR | bus error re-mapped from 0x00 for status return
|
◆ SENSORIF_I2C_Config()
| void SENSORIF_I2C_Config |
( |
u32_t |
portnum | ) |
|
Set I2C Configuration.
- Parameters
-
◆ SENSORIF_I2C_Deinit()
| void SENSORIF_I2C_Deinit |
( |
void |
| ) |
|
◆ SENSORIF_I2C_Init()
| void SENSORIF_I2C_Init |
( |
void |
| ) |
|
Initialises and enables I2C interface.
◆ SENSORIF_I2C_Read()
Reads bytes from I2C slave.
- Parameters
-
| slaveaddr | - 6-Bit Slave Address |
| pdata | - Pointer to Data Buffer |
| plen | - Pointer to Buffer Length (actual length is returned in plen) |
- Returns
- Status. 0: success, other: either I2C status or re-mapped
◆ SENSORIF_I2C_Write()
Writes bytes to I2C slave.
- Parameters
-
| slaveaddr | - 6-Bit Slave Address |
| data | - Pointer to Data Buffer |
| len | - Pointer to Buffer Length (actual length is returned in plen) |
- Returns
- Status. 0: success, other: either I2C status or re-mapped
◆ SENSORIF_PWM_Deinit()
| void SENSORIF_PWM_Deinit |
( |
void |
| ) |
|
Deinitialises and disables PWM.
◆ SENSORIF_PWM_Init()
Initialises and enables PWM for the specified frequency and duty cycle.
Note: After initialisation, change the duty cycle by calling SENSORIF_PWM_SetDutyCycle(). To change the frequency, deinitialise the PWM with SENSORIF_PWM_Deinit(), then call this function again with the required frequency.
- Parameters
-
| pin | - Number of the pin (e.g. 31) which the PWM will drive |
| u32Frequency | - Frequency of the PWM output waveform |
| u32DutyCycle | - Duty cycle as a percentage (number between 0 and 100) |
- Returns
- Error status, indicating whether the initialisation succeeded or failed.
- Return values
-
| CA_ERROR_SUCCESS | - Initialisation succeeded |
| CA_ERROR_INVALID_ARGS | - Pin doesn't support PWM |
| CA_ERROR_ALREADY | - PWM already initialised. Call Deinit() first before reinitialising. |
◆ SENSORIF_PWM_SetDutyCycle()
| void SENSORIF_PWM_SetDutyCycle |
( |
u32_t |
u32DutyCycle | ) |
|
Changes the duty cycle of the PWM.
- Parameters
-
| u32DutyCycle | - PWM Duty Cycle as a percentage (number between 0 and 100) |
◆ SENSORIF_SPI_Config()
| void SENSORIF_SPI_Config |
( |
u32_t |
portnum | ) |
|
Set SPI Configuration.
- Parameters
-
◆ SENSORIF_SPI_Deinit()
| void SENSORIF_SPI_Deinit |
( |
void |
| ) |
|
◆ SENSORIF_SPI_FULL_DUPLEX_RXONLY()
| void SENSORIF_SPI_FULL_DUPLEX_RXONLY |
( |
u8_t * |
RxBuf, |
|
|
u8_t |
RxLen |
|
) |
| |
Read data in the RX while sending IDLE data to TX.
This is intended for receive-only transmission from the slave.
- Parameters
-
| RxBuf | - read data buffer |
| RxLen | - the data length |
- Returns
- Return CA_ERROR_SUCCESS = 0x00 if successful and CA_ERROR_FAIL = 0x01 if transmit FIFO is full
◆ SENSORIF_SPI_Init()
| void SENSORIF_SPI_Init |
( |
bool |
is_eink_display_present | ) |
|
Initialises and enables SPI interface.
- Parameters
-
| is_eink_display_present | whether the SPI interface is used for communicating with a eink display. This configures it to half-duplex mode (MOSI only) and frees up PB5, which is usually used as an interrupt pin for the display. |
◆ SENSORIF_SPI_Write()
Writes bytes to SPI slave.
- Parameters
-
| out_data | - 8-bit data to send |
- Returns
- Return CA_ERROR_SUCCESS = 0x00 if successful and CA_ERROR_FAIL = 0x01 if transmit FIFO is full
◆ SENSORIF_SPI_WRITE_THEN_READ()
| void SENSORIF_SPI_WRITE_THEN_READ |
( |
u8_t * |
RxBuf, |
|
|
u8_t * |
TxBuf, |
|
|
u8_t |
RxLen, |
|
|
u8_t |
TxLen |
|
) |
| |
Exchange bytes between SPI slave and master.
*** Not being tested yet ***
- Parameters
-
| RxBuf | - read data buffer |
| TxBuf | - write data buffer |
| RxLen | - read data length |
| TxLen | - write data length This function exchange data between SPI slave and master. It is able to transmit data and receive data. |
- Returns
- Return CA_ERROR_SUCCESS = 0x00 if successful and CA_ERROR_FAIL = 0x01 if transmit FIFO is full
◆ SENSORIF_UART_Config()
| void SENSORIF_UART_Config |
( |
u32_t |
portnum | ) |
|
Set UART Configuration.
- Parameters
-
| portnum | - UART port number |
◆ SENSORIF_UART_Deinit()
| void SENSORIF_UART_Deinit |
( |
void |
| ) |
|
◆ SENSORIF_UART_Init()
| void SENSORIF_UART_Init |
( |
void |
| ) |
|
Initialises and enables UART interface.
◆ SENSORIF_UART_Read()
Read bytes to UART slave.
- Parameters
-
| in_data | - 8-bit data to read |
| readbytes | - number of bytes to read |
- Returns
- Return read bytes
◆ SENSORIF_UART_Write()
Writes bytes to UART slave.
- Parameters
-
| out_data | - 8-bit data to send |
| writebytes | - number of bytes to write |
- Returns
- Return write bytes