81 #include <stm32f4xx.h>
169 GPIO_InitStruct.
GPIO_PuPd = GPIO_PuPd_NOPULL;
172 CARME_IO2_GPIO_Out_Port_Pin, &GPIO_InitStruct,
176 CARME_IO2_OPTO_Out_Port_Pin, &GPIO_InitStruct,
180 CARME_IO2_OPTO_In_Port_Pin, &GPIO_InitStruct,
183 GPIO_InitStruct.
GPIO_PuPd = GPIO_PuPd_UP;
190 ADC_CommonInitStruct.
ADC_Mode = ADC_Mode_Independent;
215 SPI_InitStruct.
SPI_Mode = SPI_Mode_Master;
217 SPI_InitStruct.
SPI_CPOL = SPI_CPOL_High;
218 SPI_InitStruct.
SPI_CPHA = SPI_CPHA_2Edge;
219 SPI_InitStruct.
SPI_NSS = SPI_NSS_Soft | SPI_NSSInternalSoft_Set;
251 GPIO_InitStruct.
GPIO_Speed = GPIO_Speed_50MHz;
253 GPIO_InitStruct.
GPIO_PuPd = GPIO_PuPd_NOPULL;
256 CARME_IO2_GPIO_Out_Port_Pin[0].GPIO_Mode = mode;
259 CARME_IO2_GPIO_Out_Port_Pin[1].GPIO_Mode = mode;
262 CARME_IO2_GPIO_Out_Port_Pin[2].GPIO_Mode = mode;
266 CARME_IO2_GPIO_Out_Port_Pin, &GPIO_InitStruct,
282 ADC_SampleTime_15Cycles);
320 CARME_AGPIO_PIN_22 );
417 TIM_OCInitStruct.
TIM_OCMode = TIM_OCMode_PWM1;
460 CARME_AGPIO_PIN_21 );
473 uint32_t agpio_state;
500 BitVal = (Status & (1 << i)) ? Bit_SET : Bit_RESET;
502 CARME_IO2_GPIO_Out_Port_Pin[i].GPIO_Pin, BitVal);
517 uint32_t BitStatus = 0;
523 CARME_IO2_OPTO_In_Port_Pin[i].GPIO_Pin)
526 BitStatus |= (1 << i);
529 *pStatus = BitStatus;
548 BitVal = (Status & (1 << i)) ? Bit_SET : Bit_RESET;
550 CARME_IO2_OPTO_Out_Port_Pin[i].GPIO_Pin, BitVal);
#define GPIO_AF_SPI1
AF 5 selection.
uint32_t ADC_TwoSamplingDelay
#define CARME_IO2_GPIO_OUT_PIN0
static uint8_t CARME_IO2_ADC_Channels[]
CARME IO2 ADC channel list.
uint8_t ERROR_CODES
Error variable.
void TIM_Cmd(TIM_TypeDef *TIMx, FunctionalState NewState)
Enables or disables the specified TIM peripheral.
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.
static CARME_Port_Pin_t CARME_IO2_GPIO_Out_Port_Pin[]
CARME IO2 GPIO Out Port and Pin association.
GPIOOType_TypeDef GPIO_OType
uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Reads the specified input port pin.
void SPI_I2S_SendData(SPI_TypeDef *SPIx, uint16_t Data)
Transmits a Data through the SPIx/I2Sx peripheral.
void TIM_OC3Init(TIM_TypeDef *TIMx, TIM_OCInitTypeDef *TIM_OCInitStruct)
Initializes the TIMx Channel3 according to the specified parameters in the TIM_OCInitStruct.
void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
Enables or disables the High Speed APB (APB2) peripheral clock.
void TIM_OC3PreloadConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCPreload)
Enables or disables the TIMx peripheral Preload register on CCR3.
FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef *SPIx, uint16_t SPI_I2S_FLAG)
Checks whether the specified SPIx/I2Sx flag is set or not.
void CARME_IO2_SPI_CS_Out(uint8_t cs)
Generate the chip select pin.
#define CARME_IO2_LTC2622_CMD_WUn
void TIM_ARRPreloadConfig(TIM_TypeDef *TIMx, FunctionalState NewState)
Enables or disables TIMx peripheral Preload register on ARR.
void SPI_StructInit(SPI_InitTypeDef *SPI_InitStruct)
Fills each SPI_InitStruct member with its default value.
#define CARME_AGPIO_PIN_22
enum _CARME_IO2_SPI_CHANNEL CARME_IO2_SPI_CHANNEL
ADC port names.
void ADC_Cmd(ADC_TypeDef *ADCx, FunctionalState NewState)
Enables or disables the specified ADC peripheral.
uint32_t ADC_DMAAccessMode
GPIOSpeed_TypeDef GPIO_Speed
void ADC_DeInit(void)
Deinitializes all ADCs peripherals registers to their default reset values.
ADC Init structure definition.
void TIM_OC1Init(TIM_TypeDef *TIMx, TIM_OCInitTypeDef *TIM_OCInitStruct)
Initializes the TIMx Channel1 according to the specified parameters in the TIM_OCInitStruct.
void TIM_OC2Init(TIM_TypeDef *TIMx, TIM_OCInitTypeDef *TIM_OCInitStruct)
Initializes the TIMx Channel2 according to the specified parameters in the TIM_OCInitStruct.
uint16_t SPI_I2S_ReceiveData(SPI_TypeDef *SPIx)
Returns the most recent received data by the SPIx/I2Sx peripheral.
void CARME_IO2_GPIO_IN_Get(uint8_t *pStatus)
Get the GPIO In 0..3 value.
static CARME_Port_Pin_t CARME_IO2_Port_Pin[]
CARME IO2 Port and Pin association.
GPIOPuPd_TypeDef GPIO_PuPd
void CARME_GPIO_Init(CARME_Port_Pin_t *pPortPinAssociation, GPIO_InitTypeDef *pGPIO_InitStruct, uint8_t size)
Initialize GPIO ports with a CARME_Port_Pin_t table.
static CARME_Port_Pin_t CARME_IO2_OPTO_In_Port_Pin[]
CARME IO2 OPTO In Port and Pin association.
void CARME_IO2_Init(void)
CARME IO2 initialization.
uint16_t SPI_BaudRatePrescaler
void CARME_IO2_GPIO_OUT_Set(uint8_t Status)
Set the GPIO Out 0..3 value.
#define CARME_ERROR_IO2_PWM_WRONG_CHANNEL
void GPIO_StructInit(GPIO_InitTypeDef *GPIO_InitStruct)
Fills each GPIO_InitStruct member with its default value.
void CARME_IO2_ADC_Get(CARME_IO2_ADC_CHANNEL channel, uint16_t *pValue)
Get the value of an ADC channel.
TIM Output Compare Init structure definition.
CARME port and pin association structure.
#define CARME_AGPIO_PIN_108
void GPIO_WriteBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
Sets or clears the selected data port bit.
TIM Time Base Init structure definition.
void ADC_Init(ADC_TypeDef *ADCx, ADC_InitTypeDef *ADC_InitStruct)
Initializes the ADCx peripheral according to the specified parameters in the ADC_InitStruct.
void SPI_Init(SPI_TypeDef *SPIx, SPI_InitTypeDef *SPI_InitStruct)
Initializes the SPIx peripheral according to the specified parameters in the SPI_InitStruct.
void CARME_IO2_OPTO_OUT_Set(uint8_t Status)
Set the OPTO Out 0..1 value.
enum _CARME_IO2_PWM_PHASE CARME_IO2_PWM_PHASE
DC motor direction.
uint16_t ADC_GetConversionValue(ADC_TypeDef *ADCx)
Returns the last ADCx conversion result data for regular channel.
void TIM_OC1PreloadConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCPreload)
Enables or disables the TIMx peripheral Preload register on CCR1.
void ADC_CommonInit(ADC_CommonInitTypeDef *ADC_CommonInitStruct)
Initializes the ADCs peripherals according to the specified parameters in the ADC_CommonInitStruct.
GPIO Init structure definition.
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.
void CARME_AGPIO_Set(uint32_t write, uint32_t mask)
Set the AGPIO state.
SPI Init structure definition.
FlagStatus ADC_GetFlagStatus(ADC_TypeDef *ADCx, uint8_t ADC_FLAG)
Checks whether the specified ADC flag is set or not.
void ADC_SoftwareStartConv(ADC_TypeDef *ADCx)
Enables the selected ADC software start conversion of the regular channels.
void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct)
Fills each ADC_InitStruct member with its default value.
ADC Common Init structure definition.
#define CARME_IO2_GPIO_OUT_PIN2
void TIM_TimeBaseInit(TIM_TypeDef *TIMx, TIM_TimeBaseInitTypeDef *TIM_TimeBaseInitStruct)
Initializes the TIMx Time Base Unit peripheral according to the specified parameters in the TIM_TimeB...
uint8_t ADC_NbrOfConversion
static CARME_Port_Pin_t CARME_IO2_OPTO_Out_Port_Pin[]
CARME IO2 OPTO Out Port and Pin association.
void CARME_IO2_SPI_Select(CARME_IO2_SPI_CHANNEL select)
Select the peripheral SPI chip.
void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Enables or disables the Low Speed APB (APB1) peripheral clock.
void CARME_IO2_DAC_Set(CARME_IO2_DAC_CHANNEL channel, uint16_t Value)
Set the value of an DAC channel.
void TIM_DeInit(TIM_TypeDef *TIMx)
Deinitializes the TIMx peripheral registers to their default reset values.
ERROR_CODES CARME_IO2_PWM_Set(CARME_IO2_PWM_CHANNEL channel, uint16_t value)
Set the PWM time base settings.
enum _CARME_IO2_PWM_CHANNEL CARME_IO2_PWM_CHANNEL
PWM port names.
void ADC_RegularChannelConfig(ADC_TypeDef *ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime)
Configures for the selected ADC regular channel its corresponding rank in the sequencer and its sampl...
void TIM_OC2PreloadConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCPreload)
Enables or disables the TIMx peripheral Preload register on CCR2.
#define CARME_IO2_GPIO_OUT_PIN1
void CARME_AGPIO_Get(uint32_t *pStatus)
Get the AGPIO state.
void CARME_IO2_PWM_Settings(TIM_TimeBaseInitTypeDef *pTIM_TimeBaseStruct)
Set the PWM time base settings.
enum _CARME_IO2_ADC_CHANNEL CARME_IO2_ADC_CHANNEL
ADC port names.
void TIM_OC4PreloadConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCPreload)
Enables or disables the TIMx peripheral Preload register on CCR4.
BitAction
GPIO Bit SET and Bit RESET enumeration.
void CARME_IO2_PWM_Phase(CARME_IO2_PWM_PHASE dir)
Set the DC motor direction.
CARME IO2 extension module board support package.
void CARME_IO2_OPTO_IN_Get(uint8_t *pStatus)
Get the OPTO In 0..1 value.
void CARME_IO2_SPI_Receive(uint16_t *pValue)
Receive a half word from the SPI input buffer.
#define CARME_AGPIO_PIN_21
enum _CARME_IO2_DAC_CHANNEL CARME_IO2_DAC_CHANNEL
DAC port names.
void SPI_Cmd(SPI_TypeDef *SPIx, FunctionalState NewState)
Enables or disables the specified SPI peripheral.
void TIM_OC4Init(TIM_TypeDef *TIMx, TIM_OCInitTypeDef *TIM_OCInitStruct)
Initializes the TIMx Channel4 according to the specified parameters in the TIM_OCInitStruct.