CARME-M4 BSP  V1.5
CARME IO2

CARME IO2 high level functions. More...

+ Collaboration diagram for CARME IO2:

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...
 

Detailed Description

CARME IO2 high level functions.

Macro Definition Documentation

#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

GPIO Out Pin 0

Examples:
gpio_bsp.c, and pwm.c.

Definition at line 84 of file carme_io2.h.

#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.

Enumeration Type Documentation

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.

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.

Function Documentation

void CARME_IO2_ADC_Get ( CARME_IO2_ADC_CHANNEL  channel,
uint16_t *  pValue 
)

Get the value of an ADC channel.

Parameters
[in]channelADC channel which are defined in CARME_IO2_ADC_CHANNEL
[out]pValueADC value
Returns
None
Examples:
pwm.c.

Definition at line 279 of file carme_io2.c.

+ Here is the call graph for this function:

void CARME_IO2_DAC_Set ( CARME_IO2_DAC_CHANNEL  channel,
uint16_t  Value 
)

Set the value of an DAC channel.

Parameters
[in]channelDAC channel which are defined in CARME_IO2_DAC_CHANNEL
[out]ValueDAC value (12 Bit, 1mV/Bit)
Returns
None

Definition at line 298 of file carme_io2.c.

+ Here is the call graph for this function:

void CARME_IO2_GPIO_IN_Get ( uint8_t *  pStatus)

Get the GPIO In 0..3 value.

Parameters
[out]pStatusStatus of the GPIO input bits [0..3].
Returns
None

Definition at line 471 of file carme_io2.c.

+ Here is the call graph for this function:

void CARME_IO2_GPIO_OUT_Set ( uint8_t  Status)

Set the GPIO Out 0..3 value.

Parameters
[out]StatusStatus of the GPIO output bits [0..3].
Returns
None
Examples:
gpio_bsp.c.

Definition at line 492 of file carme_io2.c.

+ Here is the call graph for this function:

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.

Parameters
[in]pinPins to configure. This parameter can be any value of the following
  • CARME_IO2_GPIO_OUT_PIN0: GPIO OUT0
  • CARME_IO2_GPIO_OUT_PIN1: GPIO OUT1
  • CARME_IO2_GPIO_OUT_PIN2: GPIO OUT2
[in]modeThis parameter can be one of the following
  • CARME_IO2_GPIO_OUT_MODE_GPIO: Pin is configured as GPIO
  • CARME_IO2_GPIO_OUT_MODE_PWM: Pin is configured as PWM
Returns
None

Definition at line 245 of file carme_io2.c.

+ Here is the call graph for this function:

void CARME_IO2_Init ( void  )

CARME IO2 initialization.

Returns
None

CARME IO2 SPI bus

  • Mode = Master
  • DataSize = 16 Bit
  • CPOL = high
  • CPHA = 2 Edge
  • NSS = Soft internal
  • Baud rate prescaler = 64 (APB2 / 64)
Examples:
dma.c, gpio_bsp.c, pwm.c, and spi.c.

Definition at line 158 of file carme_io2.c.

+ Here is the call graph for this function:

void CARME_IO2_OPTO_IN_Get ( uint8_t *  pStatus)

Get the OPTO In 0..1 value.

Parameters
[out]pStatusStatus of the OPTO input bits.
Returns
None

Definition at line 514 of file carme_io2.c.

+ Here is the call graph for this function:

void CARME_IO2_OPTO_OUT_Set ( uint8_t  Status)

Set the OPTO Out 0..1 value.

Parameters
[out]StatusStatus of the OPTO input bits.
Returns
None

Definition at line 540 of file carme_io2.c.

+ Here is the call graph for this function:

void CARME_IO2_PWM_Phase ( CARME_IO2_PWM_PHASE  dir)

Set the DC motor direction.

Parameters
[in]dirDirection of the PWM signal
Returns
None

Definition at line 456 of file carme_io2.c.

+ Here is the call graph for this function:

ERROR_CODES CARME_IO2_PWM_Set ( CARME_IO2_PWM_CHANNEL  channel,
uint16_t  value 
)

Set the PWM time base settings.

Parameters
[in]channelPWM channel which are defined in CARME_IO2_PWM_CHANNEL
[in]valuePWM output value
Returns
0 = CARME_NO_ERROR
11 = CARME_ERROR_IO2_PWM_WRONG_CHANNEL
Examples:
pwm.c.

Definition at line 412 of file carme_io2.c.

+ Here is the call graph for this function:

void CARME_IO2_PWM_Settings ( TIM_TimeBaseInitTypeDef pTIM_TimeBaseStruct)

Set the PWM time base settings.

Parameters
[in]pTIM_TimeBaseStructPointer to the PWM time base init structure.
Returns
None
Examples:
pwm.c.

Definition at line 394 of file carme_io2.c.

+ Here is the call graph for this function:

void CARME_IO2_SPI_CS_Out ( uint8_t  cs)

Generate the chip select pin.

Parameters
[in]csSet the chip select pin.
  • Bit_RESET: CS = low
  • Bit_SET: CS = high
Returns
None
Examples:
spi.c.

Definition at line 333 of file carme_io2.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CARME_IO2_SPI_Receive ( uint16_t *  pValue)

Receive a half word from the SPI input buffer.

Parameters
[out]pValuePointer to the half word buffer to write data in.
Returns
None
Examples:
spi.c.

Definition at line 370 of file carme_io2.c.

+ Here is the call graph for this function:

void CARME_IO2_SPI_Select ( CARME_IO2_SPI_CHANNEL  select)

Select the peripheral SPI chip.

Parameters
[in]selectSelect nPSC0 or nPSC1
  • nPSC0: DAC (SPI0)
  • nPSC1: External (SPI1)
Returns
None
Examples:
spi.c.

Definition at line 317 of file carme_io2.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CARME_IO2_SPI_Send ( uint16_t  data)

Send a half word over the SPI port.

Parameters
[in]dataHalf word you want to send.
Returns
None
Examples:
spi.c.

Definition at line 346 of file carme_io2.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

uint8_t CARME_IO2_ADC_Channels[]
static
Initial value:
= {
ADC_Channel_8,
ADC_Channel_10,
ADC_Channel_12
}

CARME IO2 ADC channel list.

Definition at line 144 of file carme_io2.c.

CARME_Port_Pin_t CARME_IO2_GPIO_Out_Port_Pin[]
static
Initial value:
= {
{ GPIOA, GPIO_Pin_0, GPIO_Mode_OUT, GPIO_AF_TIM5 },
{ GPIOH, GPIO_Pin_11, GPIO_Mode_OUT, GPIO_AF_TIM5 },
{ GPIOH, GPIO_Pin_12, GPIO_Mode_OUT, GPIO_AF_TIM5 },
}
#define CARME_AGPIO_105
Definition: carme.h:105

CARME IO2 GPIO Out Port and Pin association.

Definition at line 118 of file carme_io2.c.

CARME_Port_Pin_t CARME_IO2_OPTO_In_Port_Pin[]
static
Initial value:
= {
}
#define CARME_AGPIO_116
Definition: carme.h:108
#define CARME_AGPIO_115
Definition: carme.h:107

CARME IO2 OPTO In Port and Pin association.

Definition at line 136 of file carme_io2.c.

CARME_Port_Pin_t CARME_IO2_OPTO_Out_Port_Pin[]
static
Initial value:
= {
}
#define CARME_AGPIO_97
Definition: carme.h:100
#define CARME_AGPIO_96
Definition: carme.h:99

CARME IO2 OPTO Out Port and Pin association.

Definition at line 128 of file carme_io2.c.

CARME_Port_Pin_t CARME_IO2_Port_Pin[]
static
Initial value:
= {
{ GPIOB, GPIO_Pin_0, GPIO_Mode_AN },
{ GPIOC, GPIO_Pin_0, GPIO_Mode_AN },
{ GPIOC, GPIO_Pin_2, GPIO_Mode_AN },
{ GPIOG, GPIO_Pin_8, GPIO_Mode_IN },
{ GPIOG, GPIO_Pin_6, GPIO_Mode_IN },
{ GPIOG, GPIO_Pin_7, GPIO_Mode_IN },
{ GPIOA, GPIO_Pin_0, GPIO_Mode_OUT, GPIO_AF_TIM5 },
{ GPIOH, GPIO_Pin_11, GPIO_Mode_OUT, GPIO_AF_TIM5 },
{ GPIOH, GPIO_Pin_12, GPIO_Mode_OUT, GPIO_AF_TIM5 },
{ GPIOA, GPIO_Pin_3, GPIO_Mode_AF, GPIO_AF_TIM5 },
{ GPIOB, GPIO_Pin_5, GPIO_Mode_AF, GPIO_AF_SPI1 },
{ GPIOA, GPIO_Pin_6, GPIO_Mode_AF, GPIO_AF_SPI1 },
{ GPIOA, GPIO_Pin_5, GPIO_Mode_AF, GPIO_AF_SPI1 },
{ GPIOA, GPIO_Pin_4, GPIO_Mode_OUT },
}
#define GPIO_AF_SPI1
AF 5 selection.
#define CARME_AGPIO_108
Definition: carme.h:106
#define CARME_AGPIO_21
Definition: carme.h:93
#define CARME_AGPIO_22
Definition: carme.h:94

CARME IO2 Port and Pin association.

Definition at line 95 of file carme_io2.c.