CARME-M4 BSP
V1.5
|
CARME IO2 high level functions. More...
Files | |
file | carme_io2.h |
CARME IO2 extension module board support package. | |
file | carme_io2.c |
CARME IO2 extension module board support package. | |
Macros | |
#define | CARME_ERROR_IO2_NO_DATA (CARME_ERROR_IO2_BASE + 0) |
#define | CARME_ERROR_IO2_PWM_WRONG_CHANNEL (CARME_ERROR_IO2_BASE + 1) |
#define | CARME_IO2_GPIO_OUT_PIN0 0x1 |
#define | CARME_IO2_GPIO_OUT_PIN1 0x2 |
#define | CARME_IO2_GPIO_OUT_PIN2 0x4 |
#define | CARME_IO2_LTC2622_CMD_W 0x00 |
#define | CARME_IO2_LTC2622_CMD_Un 0x01 |
#define | CARME_IO2_LTC2622_CMD_WUa 0x02 |
#define | CARME_IO2_LTC2622_CMD_WUn 0x03 |
#define | CARME_IO2_LTC2622_CMD_Off 0x04 |
#define | CARME_IO2_LTC2622_CMD_None 0xFF |
#define | CARME_IO2_LTC2622_ADDR_A 0x00 |
#define | CARME_IO2_LTC2622_ADDR_B 0x01 |
#define | CARME_IO2_LTC2622_ADDR_ALL 0x0F |
Typedefs | |
typedef enum _CARME_IO2_ADC_CHANNEL | CARME_IO2_ADC_CHANNEL |
ADC port names. | |
typedef enum _CARME_IO2_GPIO_OUT_MODE | CARME_IO2_GPIO_OUT_MODE |
GPIO Out mode definitions. | |
typedef enum _CARME_IO2_DAC_CHANNEL | CARME_IO2_DAC_CHANNEL |
DAC port names. | |
typedef enum _CARME_IO2_SPI_CHANNEL | CARME_IO2_SPI_CHANNEL |
ADC port names. | |
typedef enum _CARME_IO2_PWM_CHANNEL | CARME_IO2_PWM_CHANNEL |
PWM port names. | |
typedef enum _CARME_IO2_PWM_PHASE | CARME_IO2_PWM_PHASE |
DC motor direction. | |
Enumerations | |
enum | _CARME_IO2_ADC_CHANNEL { CARME_IO2_ADC_PORT0 = 0, CARME_IO2_ADC_PORT1 = 1, CARME_IO2_ADC_PORT2 = 2 } |
ADC port names. More... | |
enum | _CARME_IO2_GPIO_OUT_MODE { CARME_IO2_GPIO_OUT_MODE_GPIO = GPIO_Mode_OUT, CARME_IO2_GPIO_OUT_MODE_PWM = GPIO_Mode_AF } |
GPIO Out mode definitions. More... | |
enum | _CARME_IO2_DAC_CHANNEL { CARME_IO2_DAC_OUT0 = CARME_IO2_LTC2622_ADDR_A, CARME_IO2_DAC_OUT1 = CARME_IO2_LTC2622_ADDR_B, CARME_IO2_DAC_OUT_BOTH = CARME_IO2_LTC2622_ADDR_ALL } |
DAC port names. More... | |
enum | _CARME_IO2_SPI_CHANNEL { CARME_IO2_nPSC0 = 0, CARME_IO2_nPSC1 = 1 } |
ADC port names. More... | |
enum | _CARME_IO2_PWM_CHANNEL { CARME_IO2_PWM0, CARME_IO2_PWM1, CARME_IO2_PWM2, CARME_IO2_PWM3 } |
PWM port names. More... | |
enum | _CARME_IO2_PWM_PHASE { CARME_IO2_PWM_NORMAL_DIRECTION, CARME_IO2_PWM_OPPOSITE_DIRECTION } |
DC motor direction. More... | |
Functions | |
void | CARME_IO2_Init (void) |
CARME IO2 initialization. More... | |
void | CARME_IO2_GPIO_OUT_Settings (uint8_t pin, CARME_IO2_GPIO_OUT_MODE mode) |
Configure the CARME IO2 GPIO Out 0..2 as GPIO or PWM. More... | |
void | CARME_IO2_ADC_Get (CARME_IO2_ADC_CHANNEL channel, uint16_t *pValue) |
Get the value of an ADC channel. More... | |
void | CARME_IO2_DAC_Set (CARME_IO2_DAC_CHANNEL channel, uint16_t Value) |
Set the value of an DAC channel. More... | |
void | CARME_IO2_SPI_Select (CARME_IO2_SPI_CHANNEL select) |
Select the peripheral SPI chip. More... | |
void | CARME_IO2_SPI_CS_Out (uint8_t cs) |
Generate the chip select pin. More... | |
void | CARME_IO2_SPI_Send (uint16_t data) |
Send a half word over the SPI port. More... | |
void | CARME_IO2_SPI_Receive (uint16_t *pValue) |
Receive a half word from the SPI input buffer. More... | |
void | CARME_IO2_PWM_Settings (TIM_TimeBaseInitTypeDef *pTIM_TimeBaseStruct) |
Set the PWM time base settings. More... | |
ERROR_CODES | CARME_IO2_PWM_Set (CARME_IO2_PWM_CHANNEL channel, uint16_t value) |
Set the PWM time base settings. More... | |
void | CARME_IO2_PWM_Phase (CARME_IO2_PWM_PHASE dir) |
Set the DC motor direction. More... | |
void | CARME_IO2_GPIO_IN_Get (uint8_t *pStatus) |
Get the GPIO In 0..3 value. More... | |
void | CARME_IO2_GPIO_OUT_Set (uint8_t Status) |
Set the GPIO Out 0..3 value. More... | |
void | CARME_IO2_OPTO_IN_Get (uint8_t *pStatus) |
Get the OPTO In 0..1 value. More... | |
void | CARME_IO2_OPTO_OUT_Set (uint8_t Status) |
Set the OPTO Out 0..1 value. More... | |
Variables | |
static CARME_Port_Pin_t | CARME_IO2_Port_Pin [] |
CARME IO2 Port and Pin association. More... | |
static CARME_Port_Pin_t | CARME_IO2_GPIO_Out_Port_Pin [] |
CARME IO2 GPIO Out Port and Pin association. More... | |
static CARME_Port_Pin_t | CARME_IO2_OPTO_Out_Port_Pin [] |
CARME IO2 OPTO Out Port and Pin association. More... | |
static CARME_Port_Pin_t | CARME_IO2_OPTO_In_Port_Pin [] |
CARME IO2 OPTO In Port and Pin association. More... | |
static uint8_t | CARME_IO2_ADC_Channels [] |
CARME IO2 ADC channel list. More... | |
CARME IO2 high level functions.
#define CARME_ERROR_IO2_NO_DATA (CARME_ERROR_IO2_BASE + 0) |
No data available
Definition at line 81 of file carme_io2.h.
#define CARME_ERROR_IO2_PWM_WRONG_CHANNEL (CARME_ERROR_IO2_BASE + 1) |
Wrong PWM channel
Definition at line 82 of file carme_io2.h.
#define CARME_IO2_GPIO_OUT_PIN0 0x1 |
#define CARME_IO2_GPIO_OUT_PIN1 0x2 |
GPIO Out Pin 1
Definition at line 85 of file carme_io2.h.
#define CARME_IO2_GPIO_OUT_PIN2 0x4 |
GPIO Out Pin 2
Definition at line 86 of file carme_io2.h.
#define CARME_IO2_LTC2622_ADDR_A 0x00 |
DAC A
Definition at line 97 of file carme_io2.h.
#define CARME_IO2_LTC2622_ADDR_ALL 0x0F |
All DACs
Definition at line 99 of file carme_io2.h.
#define CARME_IO2_LTC2622_ADDR_B 0x01 |
DAC B
Definition at line 98 of file carme_io2.h.
#define CARME_IO2_LTC2622_CMD_None 0xFF |
No Operation
Definition at line 94 of file carme_io2.h.
#define CARME_IO2_LTC2622_CMD_Off 0x04 |
Power Down n
Definition at line 93 of file carme_io2.h.
#define CARME_IO2_LTC2622_CMD_Un 0x01 |
Update (Power Up) DAC Register n
Definition at line 90 of file carme_io2.h.
#define CARME_IO2_LTC2622_CMD_W 0x00 |
Write to Input Register n
Definition at line 89 of file carme_io2.h.
#define CARME_IO2_LTC2622_CMD_WUa 0x02 |
Write to Input registers, Update (Power Up) All n
Definition at line 91 of file carme_io2.h.
#define CARME_IO2_LTC2622_CMD_WUn 0x03 |
Write to and Update (Power Up) n
Definition at line 92 of file carme_io2.h.
ADC port names.
Enumerator | |
---|---|
CARME_IO2_ADC_PORT0 |
Port 0, Poti |
CARME_IO2_ADC_PORT1 |
Port 1 |
CARME_IO2_ADC_PORT2 |
Port 2 |
Definition at line 105 of file carme_io2.h.
DAC port names.
Enumerator | |
---|---|
CARME_IO2_DAC_OUT0 |
DAC Out 0 |
CARME_IO2_DAC_OUT1 |
DAC Out 1 |
CARME_IO2_DAC_OUT_BOTH |
DAC Out both |
Definition at line 124 of file carme_io2.h.
GPIO Out mode definitions.
Enumerator | |
---|---|
CARME_IO2_GPIO_OUT_MODE_GPIO |
GPIO Out mode as GPIO |
CARME_IO2_GPIO_OUT_MODE_PWM |
GPIO Out mode as PWM |
Definition at line 114 of file carme_io2.h.
PWM port names.
Enumerator | |
---|---|
CARME_IO2_PWM0 |
PWM0 |
CARME_IO2_PWM1 |
PWM1 |
CARME_IO2_PWM2 |
PWM2 |
CARME_IO2_PWM3 |
PWM3, Motor Out |
Definition at line 141 of file carme_io2.h.
enum _CARME_IO2_PWM_PHASE |
DC motor direction.
Enumerator | |
---|---|
CARME_IO2_PWM_NORMAL_DIRECTION |
Forward |
CARME_IO2_PWM_OPPOSITE_DIRECTION |
Backward |
Definition at line 151 of file carme_io2.h.
ADC port names.
Enumerator | |
---|---|
CARME_IO2_nPSC0 |
DAC, SPI0 |
CARME_IO2_nPSC1 |
External, SPI1 |
Definition at line 133 of file carme_io2.h.
void CARME_IO2_ADC_Get | ( | CARME_IO2_ADC_CHANNEL | channel, |
uint16_t * | pValue | ||
) |
Get the value of an ADC channel.
[in] | channel | ADC channel which are defined in CARME_IO2_ADC_CHANNEL |
[out] | pValue | ADC value |
Definition at line 279 of file carme_io2.c.
void CARME_IO2_DAC_Set | ( | CARME_IO2_DAC_CHANNEL | channel, |
uint16_t | Value | ||
) |
Set the value of an DAC channel.
[in] | channel | DAC channel which are defined in CARME_IO2_DAC_CHANNEL |
[out] | Value | DAC value (12 Bit, 1mV/Bit) |
Definition at line 298 of file carme_io2.c.
void CARME_IO2_GPIO_IN_Get | ( | uint8_t * | pStatus | ) |
Get the GPIO In 0..3 value.
[out] | pStatus | Status of the GPIO input bits [0..3]. |
Definition at line 471 of file carme_io2.c.
void CARME_IO2_GPIO_OUT_Set | ( | uint8_t | Status | ) |
Set the GPIO Out 0..3 value.
[out] | Status | Status of the GPIO output bits [0..3]. |
Definition at line 492 of file carme_io2.c.
void CARME_IO2_GPIO_OUT_Settings | ( | uint8_t | pin, |
CARME_IO2_GPIO_OUT_MODE | mode | ||
) |
Configure the CARME IO2 GPIO Out 0..2 as GPIO or PWM.
[in] | pin | Pins to configure. This parameter can be any value of the following
|
[in] | mode | This parameter can be one of the following
|
Definition at line 245 of file carme_io2.c.
void CARME_IO2_Init | ( | void | ) |
CARME IO2 initialization.
CARME IO2 SPI bus
Definition at line 158 of file carme_io2.c.
void CARME_IO2_OPTO_IN_Get | ( | uint8_t * | pStatus | ) |
Get the OPTO In 0..1 value.
[out] | pStatus | Status of the OPTO input bits. |
Definition at line 514 of file carme_io2.c.
void CARME_IO2_OPTO_OUT_Set | ( | uint8_t | Status | ) |
Set the OPTO Out 0..1 value.
[out] | Status | Status of the OPTO input bits. |
Definition at line 540 of file carme_io2.c.
void CARME_IO2_PWM_Phase | ( | CARME_IO2_PWM_PHASE | dir | ) |
Set the DC motor direction.
[in] | dir | Direction of the PWM signal |
Definition at line 456 of file carme_io2.c.
ERROR_CODES CARME_IO2_PWM_Set | ( | CARME_IO2_PWM_CHANNEL | channel, |
uint16_t | value | ||
) |
Set the PWM time base settings.
[in] | channel | PWM channel which are defined in CARME_IO2_PWM_CHANNEL |
[in] | value | PWM output value |
Definition at line 412 of file carme_io2.c.
void CARME_IO2_PWM_Settings | ( | TIM_TimeBaseInitTypeDef * | pTIM_TimeBaseStruct | ) |
Set the PWM time base settings.
[in] | pTIM_TimeBaseStruct | Pointer to the PWM time base init structure. |
Definition at line 394 of file carme_io2.c.
void CARME_IO2_SPI_CS_Out | ( | uint8_t | cs | ) |
Generate the chip select pin.
[in] | cs | Set the chip select pin.
|
Definition at line 333 of file carme_io2.c.
void CARME_IO2_SPI_Receive | ( | uint16_t * | pValue | ) |
Receive a half word from the SPI input buffer.
[out] | pValue | Pointer to the half word buffer to write data in. |
Definition at line 370 of file carme_io2.c.
void CARME_IO2_SPI_Select | ( | CARME_IO2_SPI_CHANNEL | select | ) |
Select the peripheral SPI chip.
[in] | select | Select nPSC0 or nPSC1
|
Definition at line 317 of file carme_io2.c.
void CARME_IO2_SPI_Send | ( | uint16_t | data | ) |
Send a half word over the SPI port.
[in] | data | Half word you want to send. |
Definition at line 346 of file carme_io2.c.
|
static |
CARME IO2 ADC channel list.
Definition at line 144 of file carme_io2.c.
|
static |
CARME IO2 GPIO Out Port and Pin association.
Definition at line 118 of file carme_io2.c.
|
static |
CARME IO2 OPTO In Port and Pin association.
Definition at line 136 of file carme_io2.c.
|
static |
CARME IO2 OPTO Out Port and Pin association.
Definition at line 128 of file carme_io2.c.
|
static |
CARME IO2 Port and Pin association.
Definition at line 95 of file carme_io2.c.