#include <compiler.h>
#include <sdrv_common.h>
#include <sdrv_uart.h>
#include <types.h>
Go to the source code of this file.
|
| lin_ret_status_e | sdrv_lin_controller_init (sdrv_lin_t *ctrl, const sdrv_lin_config_t *cfg, lin_callback_t callback, void *userdata) |
| |
| void | sdrv_lin_deinit (sdrv_lin_t *ctrl) |
| |
| lin_ret_status_e | sdrv_lin_set_baudrate (sdrv_lin_t *ctrl, uint32_t baud) |
| |
| uint8_t | sdrv_lin_get_id (sdrv_lin_t *ctrl) |
| |
| lin_ret_status_e | sdrv_lin_transmitframe (sdrv_lin_t *ctrl, sdrv_lin_pdu_t *lin_pdu, uint32_t times) |
| |
| lin_ret_status_e | sdrv_lin_transmit_status_get (sdrv_lin_t *ctrl, uint8_t *bytes_remaining) |
| |
| lin_ret_status_e | sdrv_lin_get_fifodata (sdrv_lin_t *ctrl, uint8_t *data, size_t size, uint32_t times) |
| |
| lin_ret_status_e | sdrv_lin_receiveframe (sdrv_lin_t *ctrl, sdrv_lin_pdu_t *lin_pdu) |
| |
| lin_ret_status_e | sdrv_lin_receive_status_get (sdrv_lin_t *ctrl, uint8_t *bytes_remaining) |
| |
| lin_sub_status_e | sdrv_lin_get_transfer_status (sdrv_lin_t *ctrl) |
| |
| void | sdrv_lin_clear_transfer_status (sdrv_lin_t *ctrl) |
| |
| lin_ch_status_e | sdrv_lin_get_status (sdrv_lin_t *ctrl) |
| |
| lin_ret_status_e | sdrv_lin_goto_sleep (sdrv_lin_t *ctrl) |
| |
| lin_ret_status_e | sdrv_lin_goto_sleep_internal (sdrv_lin_t *ctrl) |
| |
| lin_ret_status_e | sdrv_lin_wakeup (sdrv_lin_t *ctrl) |
| |
| lin_ret_status_e | sdrv_lin_wakeup_internal (sdrv_lin_t *ctrl) |
| |
| void | sdrv_lin_intr_ctrl (sdrv_lin_t *ctrl, uint32_t mask, bool value) |
| |
| uint32_t | sdrv_lin_intr_get (sdrv_lin_t *ctrl) |
| |
| uint32_t | sdrv_lin_intr_status_get (sdrv_lin_t *ctrl) |
| |
| void | sdrv_lin_intr_status_clear (sdrv_lin_t *ctrl, uint32_t mask) |
| |
| int | sdrv_lin_irq_handler (uint32_t irq, void *ctrl) |
| |
- Copyright
- Copyright (c) 2020 Semidrive Semiconductor. All rights reserved.
◆ ABR_PATTERN
◆ LIN_SLEEP_ID
| #define LIN_SLEEP_ID 0x3cU |
◆ LIN_WAKEUP_ID
| #define LIN_WAKEUP_ID 0x3dU |
◆ NoWait
◆ SDEV_LIN_INTR_FRAME_FIFO_ERR
| #define SDEV_LIN_INTR_FRAME_FIFO_ERR |
Value:
#define SDRV_UART_INTR_RX_FOVF
Definition: sdrv_lin.h:65
#define SDRV_LIN_INTR_FRAMEERR
Definition: sdrv_lin.h:70
#define SDRV_LIN_INTR_STARTBITERR
Definition: sdrv_lin.h:82
#define SDRV_UART_INTR_TX_FOVF
Lin interrupt bit mask.
Definition: sdrv_lin.h:63
◆ SDRV_CHAR_8_BITS
| #define SDRV_CHAR_8_BITS 0U |
◆ SDRV_DOORBELL_ABORT
| #define SDRV_DOORBELL_ABORT 0xA5C3U |
◆ SDRV_DOORBELL_TRIGGER
| #define SDRV_DOORBELL_TRIGGER 0xA53CU |
◆ SDRV_HALF_DUPLEX
| #define SDRV_HALF_DUPLEX 1U |
◆ SDRV_LIN_ABR_PATTERN_CHAR
| #define SDRV_LIN_ABR_PATTERN_CHAR 0x55U |
◆ SDRV_LIN_INTR_ABR
◆ SDRV_LIN_INTR_ABRFAIL
| #define SDRV_LIN_INTR_ABRFAIL (1U << 19) |
Auto baudrate detect error interrupt bitmask.
◆ SDRV_LIN_INTR_ABRPASS
| #define SDRV_LIN_INTR_ABRPASS (1U << 18) |
Auto baudrate detect pass interrupt bitmask.
◆ SDRV_LIN_INTR_APBCMDABORT
| #define SDRV_LIN_INTR_APBCMDABORT (1U << 22) |
APB command abort interrupt bitmask.
◆ SDRV_LIN_INTR_APBCMDDONE
| #define SDRV_LIN_INTR_APBCMDDONE (1U << 21) |
APB command completed interrupt bitmask.
◆ SDRV_LIN_INTR_BAUDRATEERR
| #define SDRV_LIN_INTR_BAUDRATEERR (1U << 10) |
Baudrate error interrupt bitmask.
◆ SDRV_LIN_INTR_FRAMEERR
| #define SDRV_LIN_INTR_FRAMEERR (1U << 9) |
Frame error interrupt bitmask. \
◆ SDRV_LIN_INTR_NOISERERR
| #define SDRV_LIN_INTR_NOISERERR (1U << 11) |
Noise error interrupt bitmask. \
◆ SDRV_LIN_INTR_PARITYERR
| #define SDRV_LIN_INTR_PARITYERR (1U << 8) |
Parity error interrupt bitmask. \
◆ SDRV_LIN_INTR_PIDERR
| #define SDRV_LIN_INTR_PIDERR (1U << 24) |
◆ SDRV_LIN_INTR_PIDPASS
| #define SDRV_LIN_INTR_PIDPASS (1U << 23) |
◆ SDRV_LIN_INTR_RXCHKSUMERR
| #define SDRV_LIN_INTR_RXCHKSUMERR (1U << 26) |
◆ SDRV_LIN_INTR_RXCHKSUMPASS
| #define SDRV_LIN_INTR_RXCHKSUMPASS (1U << 25) |
◆ SDRV_LIN_INTR_STARTBITERR
| #define SDRV_LIN_INTR_STARTBITERR (1U << 20) |
Start bit error interrupt bitmask.
◆ SDRV_LIN_OPERATION_TIMEOUT
| #define SDRV_LIN_OPERATION_TIMEOUT 0x200000U |
◆ SDRV_LIN_PCR7_PCMDTO_MASK
| #define SDRV_LIN_PCR7_PCMDTO_MASK 0x0000001FU |
◆ SDRV_LIN_PSR4_LINPID_ID_MASK
| #define SDRV_LIN_PSR4_LINPID_ID_MASK 0x0000003FU |
◆ SDRV_LIN_RXBREAK_BIT
| #define SDRV_LIN_RXBREAK_BIT |
( |
|
bit | ) |
(((bit)-9U) + 1U) |
◆ SDRV_LIN_RXBREAK_LEN
| #define SDRV_LIN_RXBREAK_LEN (10U) |
◆ SDRV_LIN_TXBREAK_BIT
| #define SDRV_LIN_TXBREAK_BIT |
( |
|
bit | ) |
(((bit)-8U) + 1U) |
◆ SDRV_LIN_TXBREAK_LEN
| #define SDRV_LIN_TXBREAK_LEN (13U) |
◆ SDRV_NO_PARITY
| #define SDRV_NO_PARITY 0U |
◆ SDRV_SOFTWARE_FC
| #define SDRV_SOFTWARE_FC 1U |
◆ SDRV_STOP_1_BIT
| #define SDRV_STOP_1_BIT 0U |
◆ SDRV_UART_INTR_RX_FOVF
| #define SDRV_UART_INTR_RX_FOVF (1U << 5) |
RX fifo overflow interrupt bit mask.
◆ SDRV_UART_INTR_TX_FOVF
| #define SDRV_UART_INTR_TX_FOVF (1U << 4) |
Lin interrupt bit mask.
TX fifo overflow interrupt bit mask.
◆ WaitForever
| #define WaitForever 0xFFFFFFFFU |
◆ lin_callback_t
◆ lin_ch_status_e
◆ lin_cs_mode_e
◆ lin_interrupt_type_e
◆ lin_mode_e
◆ lin_ret_status_e
◆ lin_sub_status_e
◆ sdrv_lin_config_t
LIN controller configure.
◆ sdrv_lin_pdu_t
◆ sdrv_lin_t
◆ lin_ch_status
LIN Channel status.
| Enumerator |
|---|
| LIN_CH_UNINITIAL_STATE | Channel uninitial
|
| LIN_CH_SLEEP_STATE | Channel sleep status
|
| LIN_CH_OPERATIONAL_STATE | Channel operational
|
◆ lin_cs_mode
LIN checksum mode.
| Enumerator |
|---|
| LIN_CLASSIC_CS | |
| LIN_ENHANCED_CS | |
◆ lin_interrupt_type
Lin interrupt event type.
| Enumerator |
|---|
| SDRV_LIN_NO_EVENT | Lin default interrupt state.
|
| SDRV_LIN_ABR_PASS | Lin auto baudrate detect pass.
|
| SDRV_LIN_ABR_FAIL | Lin auto baudrate detect fail.
|
| SDRV_LIN_TX_COMPLETE | Lin transmit completed.
|
| SDRV_LIN_TX_TIMEOUT | Lin transmit timeout.
|
| SDRV_LIN_TX_ERROR | Lin transmit error.
|
| SDRV_LIN_RX_COMPLETE | Lin receive completed.
|
| SDRV_LIN_RX_TIMEOUT | Lin receive timeout.
|
| SDRV_LIN_RX_ERROR | Lin receive error.
|
| SDRV_LIN_RX_CHECKSUM_ERR | Lin receive checksum error.
|
| SDRV_LIN_RX_PIDPASS | Lin receive pid success.
|
| SDRV_LIN_RX_PIDERR | Lin receive pid error.
|
| SDRV_LIN_RX_STARTBIT_ERR | Lin transfer start bit error.
|
| SDRV_LIN_RX_PARITY_ERR | Lin receive Parity error.
|
| SDRV_LIN_RX_FRAME_ERR | Lin receive frame error.
|
| SDRV_LIN_RX_BAUDRATE_ERR | Lin receive baudrate error.
|
| SDRV_LIN_RX_NOISE_ERR | Lin receive noise error.
|
| SDRV_LIN_RX_RXFOVF_ERR | Lin rx fifo overflow.
|
| SDRV_LIN_TX_TXFOVF_ERR | Lin tx fifo overflow.
|
◆ lin_mode
LIN mode.
| Enumerator |
|---|
| LIN_MASTER | Lin module in master mode.
|
| LIN_SLAVE | Lin module in slave mode.
|
◆ lin_ret_status
LIN return status.
| Enumerator |
|---|
| STATUS_SUCCESS | Status for success.
|
| STATUS_FAIL | Status for common error
|
| STATUS_TIMEOUT | Status for timeout.
|
| STATUS_BUSY | Status for busy.
|
| STATUS_INVALID_PARAM | |
| STATUS_SLEEP | Module in sleep mode.
|
| STATUS_UNINIT | Module should be initialized.
|
◆ lin_sub_status
LIN frame status.
| Enumerator |
|---|
| SDRV_LIN_STATE_IDLE | RX/TX line idle.
|
| SDRV_LIN_STATE_BUSY | RX/TX line busy.
|
| SDRV_LIN_STATE_TX | Lin module in transmit mode.
|
| SDRV_LIN_STATE_TX_ERROR | Lin transmit error.
|
| SDRV_LIN_STATE_RX | Lin module in receive mode.
|
| SDRV_LIN_STATE_RX_ERROR | Lin receive error.
|
| SDRV_LIN_STATE_ABR_READY | Lin auto baudrate ready.
|
| SDRV_LIN_STATE_ABR_BUSY | Lin auto baudrate detecting.
|
| SDRV_LIN_STATE_ABR_FAIL | Lin auto baudrate detect fail.
|
◆ sdrv_lin_clear_transfer_status()
| void sdrv_lin_clear_transfer_status |
( |
sdrv_lin_t * |
ctrl | ) |
|
Clear LIN tranfer status .
This function clear the state of transfer.
- Parameters
-
◆ sdrv_lin_controller_init()
LIN controller init.
This function initializes LIN controller and attach callback function. Callback fumction is optional. Please input NULL if user do not need callback function.
- Parameters
-
| [in] | ctrl | lin controller |
| [in] | cfg | lin config |
| [in] | Callback | callback function |
| [in] | userdata | callback function user param |
- Returns
- STATUS_SUCCESS : Initializing lin success. STATUS_TIMEOUT : Reset lin module fail.
◆ sdrv_lin_deinit()
LIN deinit.
This function disable the lin module, and change the state of lin channel.
- Parameters
-
◆ sdrv_lin_get_fifodata()
LIN get rx fifo data.
This function receive frame with a blocking method.
- Parameters
-
| [in] | ctrl | lin controller |
| [in] | data | the first address of the source buff to received |
| [in] | size | the size of bytes to receive |
| [in] | times | the max count of get fifo data |
- Returns
- STATUS_SUCCESS : Get data from rx fifo success. STATUS_TIMEOUT : Lin rx fifo is empty until timeout.
◆ sdrv_lin_get_id()
get lin current id.
This function get the id of current transfer. This function is only used in salve mode.
- Parameters
-
| [in] | ctrl | sdrv lin controller |
- Returns
- the id of current transfer
◆ sdrv_lin_get_status()
Get LIN node status .
This function check the state of node
- Parameters
-
- Returns
- the state of lin node
◆ sdrv_lin_get_transfer_status()
Get LIN tranfer status .
This function check the state of transfer.
- Parameters
-
- Returns
- SDRV_LIN_STATE_IDLE : The lin bus is idle. SDRV_LIN_STATE_BUSY : The lin bus is busy.
◆ sdrv_lin_goto_sleep()
LIN require slave node goto sleep.
This function send frame require slave node goto sleep.
- Parameters
-
- Returns
- STATUS_SUCCESS : Send sleep frame to slave node success. STATUS_UNINIT : The lin entity is uninitialized. STATUS_SLEEP : The lin entity is sleepy. STATUS_BUSY : The lin bus is busy. STATUS_FAIL : The size of frame is bigger than 8.
◆ sdrv_lin_goto_sleep_internal()
LIN require this node goto sleep.
This function send frame require this node goto sleep.
- Parameters
-
- Returns
- STATUS_SUCCESS : Set it's own state to LIN_CH_SLEEP_STATE success. STATUS_UNINIT : The lin entity is uninitialized.
◆ sdrv_lin_intr_ctrl()
| void sdrv_lin_intr_ctrl |
( |
sdrv_lin_t * |
ctrl, |
|
|
uint32_t |
mask, |
|
|
bool |
value |
|
) |
| |
Enable/Disable Sdrv LIN Interrupt.
This function enable/disable sdrv lin interrupt with the provided mask.
- Parameters
-
| [in] | ctrl | sdrv lin controller |
| [in] | mask | the interrupts to enable |
| [in] | value | enable or disable |
◆ sdrv_lin_intr_get()
Get Sdrv LIN Interrupt enable/disable status.
This function get sdrv lin interrupt enable/disable status with the provided mask.
- Parameters
-
| [in] | ctrl | sdrv lin controller |
- Returns
- Sdrv lin Interrupt enable/disable status
◆ sdrv_lin_intr_status_clear()
| void sdrv_lin_intr_status_clear |
( |
sdrv_lin_t * |
ctrl, |
|
|
uint32_t |
mask |
|
) |
| |
Clear Sdrv lin Interrupt flag status.
This function clear Sdrv lin Interrupt flag status with the provided mask.
- Parameters
-
| [in] | ctrl | sdrv lin controller |
| [in] | mask | the interrupts status to clear |
◆ sdrv_lin_intr_status_get()
| uint32_t sdrv_lin_intr_status_get |
( |
sdrv_lin_t * |
ctrl | ) |
|
Get Sdrv lin Interrupt flag status.
This function get Sdrv lin Interrupt flag status.
- Parameters
-
| [in] | ctrl | sdrv lin controller |
- Returns
- all sdrv lin Interrupt status
◆ sdrv_lin_irq_handler()
| int sdrv_lin_irq_handler |
( |
uint32_t |
irq, |
|
|
void * |
ctrl |
|
) |
| |
Sdrv LIN default IRQ handle function.
This function handles the sdrv lin transmit and receive and error IRQ request.
- Parameters
-
| [in] | irq | the irq number of LINx |
| [in] | ctrl | sdrv lin controller |
◆ sdrv_lin_receive_status_get()
Get LIN async receive status.
This function receive frame with a interrupt method.
- Parameters
-
| [in] | ctrl | lin controller |
| [in] | bytes_remaining | the number of bytes that still needed to receive |
- Returns
- STATUS_SUCCESS : Lin receive the frame success. STATUS_BUSY : Lin receive the frame not finished. STATUS_FAIL : Lin receive the frame fail.
◆ sdrv_lin_receiveframe()
LIN receive frame.
This function receive frame with a blocking method.
- Parameters
-
| [in] | ctrl | lin controller |
| [in] | lin_pdu | the info of receive param, include id: the id of current transfer; checksum: the checksum of current transfer; size: the data size of current transfer; data: the data buffer of current transfer. |
- Returns
- STATUS_SUCCESS : Triger lin receive process success. STATUS_UNINIT : The lin entity is uninitialized. STATUS_SLEEP : The lin entity is sleepy. STATUS_BUSY : The lin bus is busy. STATUS_FAIL : The size of frame is bigger than 8.
◆ sdrv_lin_set_baudrate()
Configure lin baud rate.
This function configures the lin module baud rate. This function is used to update the lin module baud rate. after the lin module is initialized by the sdrv_lin_init.
- Parameters
-
| [in] | ctrl | sdrv lin controller |
| [in] | baud | baud |
- Returns
- STATUS_SUCCESS : Setting lin baudrate success. STATUS_INVALID_PARAM : The param is unvalid. STATUS_UNINIT : The lin entity is uninitialized.
◆ sdrv_lin_transmit_status_get()
Get LIN transmit status.
This function get status of transmit frame.
- Parameters
-
| [in] | ctrl | lin controller |
| [in] | bytes_remaining | the number of bytes that still needed to transmit |
- Returns
- STATUS_SUCCESS : Lin transmit the frame success. STATUS_BUSY : Lin transmit the frame not finished. STATUS_FAIL : Lin transmit the frame fail.
◆ sdrv_lin_transmitframe()
LIN transmit frame.
This function transmit frame with a blocking method.
- Parameters
-
| [in] | ctrl | lin controller |
| [in] | lin_pdu | the info of transmit param, include id: the id of current transfer; checksum: the checksum of current transfer; size: the data size of current transfer; data: the data buffer of current transfer. |
| [in] | times | timeout count |
- Returns
- STATUS_SUCCESS : Triger lin transmit process success. STATUS_UNINIT : The lin entity is uninitialized. STATUS_SLEEP : The lin entity is sleepy. STATUS_BUSY : The lin bus is busy. STATUS_FAIL : The size of frame is bigger than 8.
◆ sdrv_lin_wakeup()
LIN remote node wakeup.
This function wakup the remote node.
- Parameters
-
- Returns
- STATUS_SUCCESS : Send wakeup frame to slave node success. STATUS_UNINIT : The lin entity is uninitialized. STATUS_SLEEP : The lin entity is sleepy. STATUS_BUSY : The lin bus is busy. STATUS_FAIL : The size of frame is bigger than 8.
◆ sdrv_lin_wakeup_internal()
LIN node wakeup.
This function wakup this node.
- Parameters
-
- Returns
- STATUS_SUCCESS : Set it's own state to LIN_CH_OPERATIONAL_STATE success. STATUS_UNINIT : The lin entity is uninitialized.