HPM SDK
HPMicro Software Development Kit
LINV2 driver APIs

LINV2 driver APIs. More...

Data Structures

struct  lin_timing_t
 
struct  lin_trans_config_t
 LIN config. More...
 

Macros

#define LIN_ID_DATA_LEN_SHIFT   4U
 
#define LIN_ID_DATA_LEN_MASK   0x30U
 
#define LIN_ID_DATA_LEN_GET(x)   (((uint8_t)(x) & LIN_ID_DATA_LEN_MASK) >> LIN_ID_DATA_LEN_SHIFT)
 

Enumerations

enum  lin_id_data_length_t {
  id_data_length_2bytes , id_data_length_2bytes_2 , id_data_length_4bytes , id_data_length_8bytes ,
  id_data_length_2bytes , id_data_length_2bytes_2 , id_data_length_4bytes , id_data_length_8bytes
}
 data length in ID bit4 and bit5 More...
 
enum  lin_bus_inactivity_time_t {
  bus_inactivity_time_4s , bus_inactivity_time_6s , bus_inactivity_time_8s , bus_inactivity_time_10s ,
  bus_inactivity_time_4s , bus_inactivity_time_6s , bus_inactivity_time_8s , bus_inactivity_time_10s
}
 bus inactivity tome to go to sleep More...
 
enum  lin_wakeup_repeat_time_t {
  wakeup_repeat_time_180ms , wakeup_repeat_time_200ms , wakeup_repeat_time_220ms , wakeup_repeat_time_240ms ,
  wakeup_repeat_time_180ms , wakeup_repeat_time_200ms , wakeup_repeat_time_220ms , wakeup_repeat_time_240ms
}
 wakeup repeat time More...
 

Functions

static uint32_t lin_get_control_and_status (LINV2_Type *ptr)
 lin get control and status register value More...
 
static void lin_reset_interrupt (LINV2_Type *ptr)
 lin reset interrupt More...
 
static void lin_reset_error (LINV2_Type *ptr)
 lin reset error More...
 
static void lin_wakeup (LINV2_Type *ptr)
 lin wakeup More...
 
static void lin_sleep (LINV2_Type *ptr)
 lin sleep More...
 
static void lin_slave_stop (LINV2_Type *ptr)
 lin slave stop More...
 
static void lin_slave_ack (LINV2_Type *ptr)
 lin slave ack More...
 
static void lin_slave_set_bus_inactivity_time (LINV2_Type *ptr, lin_bus_inactivity_time_t time)
 lin slave set bus inactivity time More...
 
static void lin_slave_set_wakeup_repeat_time (LINV2_Type *ptr, lin_wakeup_repeat_time_t time)
 lin slave set wakeup repeat time More...
 
static void lin_set_mode (LINV2_Type *ptr, bool master)
 lin set mode More...
 
static void lin_set_checksum_mode (LINV2_Type *ptr, bool enhance_checksum)
 lin set checksum mode More...
 
static uint8_t lin_get_data_byte (LINV2_Type *ptr, uint8_t index)
 lin get data value in byte More...
 
static void lin_write_data_byte (LINV2_Type *ptr, uint8_t index, uint8_t data)
 lin write data value in byte More...
 
static uint8_t lin_get_id (LINV2_Type *ptr)
 lin get ID More...
 
static uint8_t lin_get_checksum (LINV2_Type *ptr)
 lin get checksum value More...
 
static uint8_t lin_is_active (LINV2_Type *ptr)
 lin active status More...
 
static uint8_t lin_is_complete (LINV2_Type *ptr)
 lin complete status More...
 
hpm_stat_t lin_master_configure_timing (LINV2_Type *ptr, lin_timing_t *timing)
 lin configure timing on master mode More...
 
hpm_stat_t lin_slave_configure_timing (LINV2_Type *ptr, uint32_t src_freq_in_hz)
 lin config timing on slave mode More...
 
void lin_master_transfer (LINV2_Type *ptr, lin_trans_config_t *config)
 lin transfer on master mode More...
 
void lin_slave_transfer (LINV2_Type *ptr, lin_trans_config_t *config)
 lin transfer on slave mode More...
 
uint8_t lin_get_data_length (LINV2_Type *ptr)
 get data length More...
 
hpm_stat_t lin_master_sent (LINV2_Type *ptr, lin_trans_config_t *config)
 lin send data on master mode More...
 
hpm_stat_t lin_master_receive (LINV2_Type *ptr, lin_trans_config_t *config)
 lin receive data on master mode More...
 
hpm_stat_t lin_slave_sent (LINV2_Type *ptr, lin_trans_config_t *config)
 lin send data on slave mode More...
 
hpm_stat_t lin_slave_receive (LINV2_Type *ptr, lin_trans_config_t *config)
 lin receive data on slave mode More...
 
void lin_slave_dma_transfer (LINV2_Type *ptr, lin_trans_config_t *config)
 lin slave dma transfer More...
 

Detailed Description

LINV2 driver APIs.

Macro Definition Documentation

◆ LIN_ID_DATA_LEN_GET

#define LIN_ID_DATA_LEN_GET (   x)    (((uint8_t)(x) & LIN_ID_DATA_LEN_MASK) >> LIN_ID_DATA_LEN_SHIFT)

◆ LIN_ID_DATA_LEN_MASK

#define LIN_ID_DATA_LEN_MASK   0x30U

◆ LIN_ID_DATA_LEN_SHIFT

#define LIN_ID_DATA_LEN_SHIFT   4U

#include <drivers/inc/hpm_linv2_drv.h>

bit4 and bit5 encode data length in ID

Enumeration Type Documentation

◆ lin_bus_inactivity_time_t

#include <drivers/inc/hpm_linv2_drv.h>

bus inactivity tome to go to sleep

Enumerator
bus_inactivity_time_4s 
bus_inactivity_time_6s 
bus_inactivity_time_8s 
bus_inactivity_time_10s 
bus_inactivity_time_4s 
bus_inactivity_time_6s 
bus_inactivity_time_8s 
bus_inactivity_time_10s 

◆ lin_id_data_length_t

#include <drivers/inc/hpm_linv2_drv.h>

data length in ID bit4 and bit5

Enumerator
id_data_length_2bytes 
id_data_length_2bytes_2 

both 0 and 1 represent 2 bytes

id_data_length_4bytes 
id_data_length_8bytes 
id_data_length_2bytes 
id_data_length_2bytes_2 

both 0 and 1 represent 2 bytes

id_data_length_4bytes 
id_data_length_8bytes 

◆ lin_wakeup_repeat_time_t

#include <drivers/inc/hpm_linv2_drv.h>

wakeup repeat time

Enumerator
wakeup_repeat_time_180ms 
wakeup_repeat_time_200ms 
wakeup_repeat_time_220ms 
wakeup_repeat_time_240ms 
wakeup_repeat_time_180ms 
wakeup_repeat_time_200ms 
wakeup_repeat_time_220ms 
wakeup_repeat_time_240ms 

Function Documentation

◆ lin_get_checksum()

static uint8_t lin_get_checksum ( LINV2_Type ptr)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin get checksum value

Parameters
ptrlin base address
Returns
uint8_t checksum value

◆ lin_get_control_and_status()

static uint32_t lin_get_control_and_status ( LINV2_Type ptr)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin get control and status register value

Parameters
[in]ptrlin base address
Returns
uint32_t control and status register value

◆ lin_get_data_byte()

static uint8_t lin_get_data_byte ( LINV2_Type ptr,
uint8_t  index 
)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin get data value in byte

Parameters
ptrlin base address
indexbyte index
Returns
uint8_t byte value

◆ lin_get_data_length()

uint8_t lin_get_data_length ( LINV2_Type ptr)

#include <drivers/inc/hpm_linv2_drv.h>

get data length

Note
data length is determined by DATA_LEN register and ID
Parameters
ptrlin base address
Returns
uint8_t data length

◆ lin_get_id()

static uint8_t lin_get_id ( LINV2_Type ptr)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin get ID

Parameters
ptrlin base address
Returns
uint8_t ID value

◆ lin_is_active()

static uint8_t lin_is_active ( LINV2_Type ptr)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin active status

Parameters
ptrlin base address
Returns
bool true for active, false for inactive

◆ lin_is_complete()

static uint8_t lin_is_complete ( LINV2_Type ptr)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin complete status

Parameters
ptrlin base address
Returns
bool true for complete, false for incomplete

◆ lin_master_configure_timing()

hpm_stat_t lin_master_configure_timing ( LINV2_Type ptr,
lin_timing_t timing 
)

#include <drivers/inc/hpm_linv2_drv.h>

lin configure timing on master mode

Parameters
ptrlin base address
timinglin_timing_t
Returns
hpm_stat_t

set master mode

src =20MHz baudrate = 19.2KHz

bt_div = 260, scaler = 1, bt_mul = 0

◆ lin_master_receive()

hpm_stat_t lin_master_receive ( LINV2_Type ptr,
lin_trans_config_t config 
)

#include <drivers/inc/hpm_linv2_drv.h>

lin receive data on master mode

Parameters
ptrlin base address
configlin_trans_config_t
Returns
status_timeout
status_success

waiting for lin inactive

config id

receive

start

waiting for receive complete

load register data into buffer

◆ lin_master_sent()

hpm_stat_t lin_master_sent ( LINV2_Type ptr,
lin_trans_config_t config 
)

#include <drivers/inc/hpm_linv2_drv.h>

lin send data on master mode

Parameters
ptrlin base address
configlin_trans_config_t
Returns
status_timeout
status_success

wait for lin inactive

config id

load data into registers

start

waiting for lin complete

◆ lin_master_transfer()

void lin_master_transfer ( LINV2_Type ptr,
lin_trans_config_t config 
)

#include <drivers/inc/hpm_linv2_drv.h>

lin transfer on master mode

Parameters
ptrlin base address
configlin_trans_config_t

config id

sent or receive

start

◆ lin_reset_error()

static void lin_reset_error ( LINV2_Type ptr)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin reset error

Parameters
ptrlin base address

◆ lin_reset_interrupt()

static void lin_reset_interrupt ( LINV2_Type ptr)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin reset interrupt

Parameters
ptrlin base address

◆ lin_set_checksum_mode()

static void lin_set_checksum_mode ( LINV2_Type ptr,
bool  enhance_checksum 
)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin set checksum mode

Parameters
ptrlin base address
enhance_checksumtrue for enhance checksum mode, false for normal checksum mode

◆ lin_set_mode()

static void lin_set_mode ( LINV2_Type ptr,
bool  master 
)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin set mode

Parameters
ptrlin base address
mastertrue for master mode, false for slave mode

◆ lin_slave_ack()

static void lin_slave_ack ( LINV2_Type ptr)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin slave ack

Parameters
ptrlin base address

◆ lin_slave_configure_timing()

hpm_stat_t lin_slave_configure_timing ( LINV2_Type ptr,
uint32_t  src_freq_in_hz 
)

#include <drivers/inc/hpm_linv2_drv.h>

lin config timing on slave mode

Parameters
ptrlin base address
src_freq_in_hzsource frequency
Returns
hpm_stat_t

set slave mode, clean bt_div, bit_mul, prescl

src = 20MHz, prescaler = 1, bt_div = 250

◆ lin_slave_dma_transfer()

void lin_slave_dma_transfer ( LINV2_Type ptr,
lin_trans_config_t config 
)

#include <drivers/inc/hpm_linv2_drv.h>

lin slave dma transfer

Parameters
ptrlin base address
configlin_trans_config_t

◆ lin_slave_receive()

hpm_stat_t lin_slave_receive ( LINV2_Type ptr,
lin_trans_config_t config 
)

#include <drivers/inc/hpm_linv2_drv.h>

lin receive data on slave mode

Parameters
ptrlin base address
configlin_trans_config_t
Returns
status_timeout
status_success

waiting for lin data_req

receive

data ack

waiting for lin complete

◆ lin_slave_sent()

hpm_stat_t lin_slave_sent ( LINV2_Type ptr,
lin_trans_config_t config 
)

#include <drivers/inc/hpm_linv2_drv.h>

lin send data on slave mode

Parameters
ptrlin base address
configlin_trans_config_t
Returns
status_timeout
status_success

waiting for lin data_req

transmit

data ack

waiting for lin complete

◆ lin_slave_set_bus_inactivity_time()

static void lin_slave_set_bus_inactivity_time ( LINV2_Type ptr,
lin_bus_inactivity_time_t  time 
)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin slave set bus inactivity time

Parameters
ptrlin base address
timelin_bus_inactivity_time_t

◆ lin_slave_set_wakeup_repeat_time()

static void lin_slave_set_wakeup_repeat_time ( LINV2_Type ptr,
lin_wakeup_repeat_time_t  time 
)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin slave set wakeup repeat time

Parameters
ptrlin base address
timelin_wakeup_repeat_time_t

◆ lin_slave_stop()

static void lin_slave_stop ( LINV2_Type ptr)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin slave stop

Parameters
ptrlin base address

◆ lin_slave_transfer()

void lin_slave_transfer ( LINV2_Type ptr,
lin_trans_config_t config 
)

#include <drivers/inc/hpm_linv2_drv.h>

lin transfer on slave mode

Note
call this function after lin generate data request interrupt
Parameters
ptrlin base address
configlin_trans_config_t

transmit or receive

data ack

◆ lin_sleep()

static void lin_sleep ( LINV2_Type ptr)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin sleep

Parameters
ptrlin base address

◆ lin_wakeup()

static void lin_wakeup ( LINV2_Type ptr)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin wakeup

Parameters
ptrlin base address

◆ lin_write_data_byte()

static void lin_write_data_byte ( LINV2_Type ptr,
uint8_t  index,
uint8_t  data 
)
inlinestatic

#include <drivers/inc/hpm_linv2_drv.h>

lin write data value in byte

Parameters
ptrlin base address
indexbyte index
databyte value