CARME-M4 BSP  V1.5
carme_io2.h
Go to the documentation of this file.
1 #ifndef __CARME_IO2_H__
2 #define __CARME_IO2_H__
3 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif /* __cplusplus */
75 
76 /*----- Header-Files -------------------------------------------------------*/
77 #include <stm32f4xx.h> /* Processor STM32F407IG */
78 #include <carme.h> /* CARME Module */
79 
80 /*----- Macros -------------------------------------------------------------*/
81 #define CARME_ERROR_IO2_NO_DATA (CARME_ERROR_IO2_BASE + 0)
82 #define CARME_ERROR_IO2_PWM_WRONG_CHANNEL (CARME_ERROR_IO2_BASE + 1)
84 #define CARME_IO2_GPIO_OUT_PIN0 0x1
85 #define CARME_IO2_GPIO_OUT_PIN1 0x2
86 #define CARME_IO2_GPIO_OUT_PIN2 0x4
88 /* LTC2622 DAC Commands */
89 #define CARME_IO2_LTC2622_CMD_W 0x00
90 #define CARME_IO2_LTC2622_CMD_Un 0x01
91 #define CARME_IO2_LTC2622_CMD_WUa 0x02
92 #define CARME_IO2_LTC2622_CMD_WUn 0x03
93 #define CARME_IO2_LTC2622_CMD_Off 0x04
94 #define CARME_IO2_LTC2622_CMD_None 0xFF
96 /* LTC2622 DAC Addresses */
97 #define CARME_IO2_LTC2622_ADDR_A 0x00
98 #define CARME_IO2_LTC2622_ADDR_B 0x01
99 #define CARME_IO2_LTC2622_ADDR_ALL 0x0F
101 /*----- Data types ---------------------------------------------------------*/
102 
110 
120 
129 
137 
147 
151 typedef enum _CARME_IO2_PWM_PHASE {
155 
156 /*----- Function prototypes ------------------------------------------------*/
157 extern void CARME_IO2_Init(void);
158 extern void CARME_IO2_GPIO_OUT_Settings(uint8_t pin,
160 extern void CARME_IO2_ADC_Get(CARME_IO2_ADC_CHANNEL channel, uint16_t *pValue);
161 extern void CARME_IO2_DAC_Set(CARME_IO2_DAC_CHANNEL channel, uint16_t Value);
162 extern void CARME_IO2_SPI_Select(CARME_IO2_SPI_CHANNEL select);
163 extern void CARME_IO2_SPI_CS_Out(uint8_t cs);
164 extern void CARME_IO2_SPI_Send(uint16_t data);
165 extern void CARME_IO2_SPI_Receive(uint16_t *pValue);
166 extern void CARME_IO2_PWM_Settings(
167  TIM_TimeBaseInitTypeDef *pTIM_TimeBaseStruct);
169  uint16_t value);
171 extern void CARME_IO2_GPIO_IN_Get(uint8_t *pStatus);
172 extern void CARME_IO2_GPIO_OUT_Set(uint8_t Status);
173 extern void CARME_IO2_OPTO_IN_Get(uint8_t *pStatus);
174 extern void CARME_IO2_OPTO_OUT_Set(uint8_t Status);
175 
176 /*----- Data ---------------------------------------------------------------*/
177 
178 #ifdef __cplusplus
179 }
180 #endif /* __cplusplus */
181 
187 #endif /* __CARME_IO2_H__ */
_CARME_IO2_DAC_CHANNEL
DAC port names.
Definition: carme_io2.h:124
_CARME_IO2_PWM_CHANNEL
PWM port names.
Definition: carme_io2.h:141
uint8_t ERROR_CODES
Error variable.
Definition: carme.h:255
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.
Definition: carme_io2.c:245
#define CARME_IO2_LTC2622_ADDR_B
Definition: carme_io2.h:98
void CARME_IO2_SPI_CS_Out(uint8_t cs)
Generate the chip select pin.
Definition: carme_io2.c:333
enum _CARME_IO2_SPI_CHANNEL CARME_IO2_SPI_CHANNEL
ADC port names.
void CARME_IO2_GPIO_IN_Get(uint8_t *pStatus)
Get the GPIO In 0..3 value.
Definition: carme_io2.c:471
void CARME_IO2_Init(void)
CARME IO2 initialization.
Definition: carme_io2.c:158
void CARME_IO2_GPIO_OUT_Set(uint8_t Status)
Set the GPIO Out 0..3 value.
Definition: carme_io2.c:492
void CARME_IO2_ADC_Get(CARME_IO2_ADC_CHANNEL channel, uint16_t *pValue)
Get the value of an ADC channel.
Definition: carme_io2.c:279
TIM Time Base Init structure definition.
Definition: stm32f4xx_tim.h:55
void CARME_IO2_OPTO_OUT_Set(uint8_t Status)
Set the OPTO Out 0..1 value.
Definition: carme_io2.c:540
enum _CARME_IO2_PWM_PHASE CARME_IO2_PWM_PHASE
DC motor direction.
_CARME_IO2_SPI_CHANNEL
ADC port names.
Definition: carme_io2.h:133
_CARME_IO2_ADC_CHANNEL
ADC port names.
Definition: carme_io2.h:105
enum _CARME_IO2_GPIO_OUT_MODE CARME_IO2_GPIO_OUT_MODE
GPIO Out mode definitions.
void CARME_IO2_SPI_Send(uint16_t data)
Send a half word over the SPI port.
Definition: carme_io2.c:346
#define CARME_IO2_LTC2622_ADDR_A
Definition: carme_io2.h:97
void CARME_IO2_SPI_Select(CARME_IO2_SPI_CHANNEL select)
Select the peripheral SPI chip.
Definition: carme_io2.c:317
void CARME_IO2_DAC_Set(CARME_IO2_DAC_CHANNEL channel, uint16_t Value)
Set the value of an DAC channel.
Definition: carme_io2.c:298
ERROR_CODES CARME_IO2_PWM_Set(CARME_IO2_PWM_CHANNEL channel, uint16_t value)
Set the PWM time base settings.
Definition: carme_io2.c:412
#define CARME_IO2_LTC2622_ADDR_ALL
Definition: carme_io2.h:99
enum _CARME_IO2_PWM_CHANNEL CARME_IO2_PWM_CHANNEL
PWM port names.
void CARME_IO2_PWM_Settings(TIM_TimeBaseInitTypeDef *pTIM_TimeBaseStruct)
Set the PWM time base settings.
Definition: carme_io2.c:394
enum _CARME_IO2_ADC_CHANNEL CARME_IO2_ADC_CHANNEL
ADC port names.
void CARME_IO2_PWM_Phase(CARME_IO2_PWM_PHASE dir)
Set the DC motor direction.
Definition: carme_io2.c:456
_CARME_IO2_GPIO_OUT_MODE
GPIO Out mode definitions.
Definition: carme_io2.h:114
void CARME_IO2_OPTO_IN_Get(uint8_t *pStatus)
Get the OPTO In 0..1 value.
Definition: carme_io2.c:514
void CARME_IO2_SPI_Receive(uint16_t *pValue)
Receive a half word from the SPI input buffer.
Definition: carme_io2.c:370
_CARME_IO2_PWM_PHASE
DC motor direction.
Definition: carme_io2.h:151
enum _CARME_IO2_DAC_CHANNEL CARME_IO2_DAC_CHANNEL
DAC port names.