CARME-M4 BSP  V1.5
carme_io2.c
Go to the documentation of this file.
1 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif /* __cplusplus */
79 
80 /*----- Header-Files -------------------------------------------------------*/
81 #include <stm32f4xx.h> /* Processor STM32F407IG */
82 #include <carme.h> /* CARME Module */
83 #include <carme_io2.h> /* CARME IO2 Module */
84 
85 /*----- Macros -------------------------------------------------------------*/
86 
87 /*----- Data types ---------------------------------------------------------*/
88 
89 /*----- Function prototypes ------------------------------------------------*/
90 
91 /*----- Data ---------------------------------------------------------------*/
96  { GPIOB, GPIO_Pin_0, GPIO_Mode_AN },
97  { GPIOC, GPIO_Pin_0, GPIO_Mode_AN },
98  { GPIOC, GPIO_Pin_2, GPIO_Mode_AN },
99  { GPIOG, GPIO_Pin_8, GPIO_Mode_IN },
100  { GPIOG, GPIO_Pin_6, GPIO_Mode_IN },
101  { GPIOG, GPIO_Pin_7, GPIO_Mode_IN },
104  { GPIOA, GPIO_Pin_0, GPIO_Mode_OUT, GPIO_AF_TIM5 },
105  { GPIOH, GPIO_Pin_11, GPIO_Mode_OUT, GPIO_AF_TIM5 },
106  { GPIOH, GPIO_Pin_12, GPIO_Mode_OUT, GPIO_AF_TIM5 },
107  { GPIOA, GPIO_Pin_3, GPIO_Mode_AF, GPIO_AF_TIM5 },
108  { GPIOB, GPIO_Pin_5, GPIO_Mode_AF, GPIO_AF_SPI1 },
109  { GPIOA, GPIO_Pin_6, GPIO_Mode_AF, GPIO_AF_SPI1 },
110  { GPIOA, GPIO_Pin_5, GPIO_Mode_AF, GPIO_AF_SPI1 },
111  { GPIOA, GPIO_Pin_4, GPIO_Mode_OUT },
113 };
114 
119  { GPIOA, GPIO_Pin_0, GPIO_Mode_OUT, GPIO_AF_TIM5 },
120  { GPIOH, GPIO_Pin_11, GPIO_Mode_OUT, GPIO_AF_TIM5 },
121  { GPIOH, GPIO_Pin_12, GPIO_Mode_OUT, GPIO_AF_TIM5 },
123 };
124 
131 };
132 
139 };
140 
144 static uint8_t CARME_IO2_ADC_Channels[] = {
145  ADC_Channel_8,
146  ADC_Channel_10,
147  ADC_Channel_12
148 };
149 
150 /*----- Implementation -----------------------------------------------------*/
158 void CARME_IO2_Init(void) {
159 
160  GPIO_InitTypeDef GPIO_InitStruct;
161  ADC_CommonInitTypeDef ADC_CommonInitStruct;
162  ADC_InitTypeDef ADC_InitStruct;
163  SPI_InitTypeDef SPI_InitStruct;
164 
165  /* Initialize the GPIO */
166  GPIO_StructInit(&GPIO_InitStruct);
167  GPIO_InitStruct.GPIO_Speed = GPIO_Fast_Speed;
168  GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
169  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
170 
172  CARME_IO2_GPIO_Out_Port_Pin, &GPIO_InitStruct,
173  sizeof(CARME_IO2_GPIO_Out_Port_Pin) / sizeof(CARME_Port_Pin_t));
174 
176  CARME_IO2_OPTO_Out_Port_Pin, &GPIO_InitStruct,
177  sizeof(CARME_IO2_OPTO_Out_Port_Pin) / sizeof(CARME_Port_Pin_t));
178 
180  CARME_IO2_OPTO_In_Port_Pin, &GPIO_InitStruct,
181  sizeof(CARME_IO2_OPTO_In_Port_Pin) / sizeof(CARME_Port_Pin_t));
182 
183  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
184  CARME_GPIO_Init(CARME_IO2_Port_Pin, &GPIO_InitStruct,
185  sizeof(CARME_IO2_Port_Pin) / sizeof(CARME_Port_Pin_t));
186 
187  /* Initialize the ADC */
188  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
189  ADC_DeInit();
190  ADC_CommonInitStruct.ADC_Mode = ADC_Mode_Independent;
191  ADC_CommonInitStruct.ADC_Prescaler = ADC_Prescaler_Div2;
192  ADC_CommonInitStruct.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
193  ADC_CommonInitStruct.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
194  ADC_CommonInit(&ADC_CommonInitStruct);
195  ADC_StructInit(&ADC_InitStruct);
196  ADC_InitStruct.ADC_Resolution = ADC_Resolution_10b;
197  ADC_InitStruct.ADC_NbrOfConversion = 1;
198  ADC_Init(ADC1, &ADC_InitStruct);
199  ADC_Cmd(ADC1, ENABLE);
200 
201  /* Initialize the SPI */
202  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
203  CARME_IO2_SPI_CS_Out(Bit_SET); /* set CS high */
204  SPI_DeInit(SPI1);
214  SPI_StructInit(&SPI_InitStruct);
215  SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
216  SPI_InitStruct.SPI_DataSize = SPI_DataSize_16b;
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;
220  SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64;
221  SPI_Init(SPI1, &SPI_InitStruct);
222  SPI_Cmd(SPI1, ENABLE);
223 
224  /* Initialize the PWM */
225  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE);
226 }
227 
246 
247  GPIO_InitTypeDef GPIO_InitStruct;
248 
249  /* Initialize the GPIO */
250  GPIO_StructInit(&GPIO_InitStruct);
251  GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
252  GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
253  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
254 
255  if (pin & CARME_IO2_GPIO_OUT_PIN0) {
256  CARME_IO2_GPIO_Out_Port_Pin[0].GPIO_Mode = mode;
257  }
258  if (pin & CARME_IO2_GPIO_OUT_PIN1) {
259  CARME_IO2_GPIO_Out_Port_Pin[1].GPIO_Mode = mode;
260  }
261  if (pin & CARME_IO2_GPIO_OUT_PIN2) {
262  CARME_IO2_GPIO_Out_Port_Pin[2].GPIO_Mode = mode;
263  }
264 
266  CARME_IO2_GPIO_Out_Port_Pin, &GPIO_InitStruct,
267  sizeof(CARME_IO2_GPIO_Out_Port_Pin) / sizeof(CARME_Port_Pin_t));
268 }
269 
279 void CARME_IO2_ADC_Get(CARME_IO2_ADC_CHANNEL channel, uint16_t *pValue) {
280 
281  ADC_RegularChannelConfig(ADC1, CARME_IO2_ADC_Channels[channel], 1,
282  ADC_SampleTime_15Cycles);
283  ADC_SoftwareStartConv(ADC1);
284  while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC));
285  *pValue = ADC_GetConversionValue(ADC1) & 0x03FF;
286 }
287 
298 void CARME_IO2_DAC_Set(CARME_IO2_DAC_CHANNEL channel, uint16_t Value) {
299 
300  CARME_IO2_SPI_Select(CARME_IO2_nPSC0); /* Use SPI0 to DAC */
301  CARME_IO2_SPI_CS_Out(Bit_RESET); /* set CS low */
303  CARME_IO2_SPI_Send(Value << 4); /* 12 Bit value and 4 don't care*/
304  CARME_IO2_SPI_CS_Out(Bit_SET); /* set CS high */
305 }
306 
318 
320  CARME_AGPIO_PIN_22 );
321 }
322 
333 void CARME_IO2_SPI_CS_Out(uint8_t cs) {
334 
335  GPIO_WriteBit(GPIOA, GPIO_Pin_4, cs);
336 }
337 
346 void CARME_IO2_SPI_Send(uint16_t data) {
347 
348  /* write data to be transmitted to the SPI data register */
349  SPI_I2S_SendData(SPI1, data);
350 
351  /* wait until transmit complete */
352  while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET)
353  ;
354  /* wait until receive complete */
355  while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET)
356  ;
357  /* wait until SPI is not busy anymore */
358  while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET)
359  ;
360 }
361 
370 void CARME_IO2_SPI_Receive(uint16_t *pValue) {
371 
372  /* wait until transmit complete */
373  while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET)
374  ;
375  /* wait until receive complete */
376  while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET)
377  ;
378  /* wait until SPI is not busy anymore */
379  while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET)
380  ;
381 
382  *pValue = SPI_I2S_ReceiveData(SPI1);
383 }
384 
395 
396  TIM_Cmd(TIM5, DISABLE);
397  TIM_DeInit(TIM5);
398  TIM_TimeBaseInit(TIM5, pTIM_TimeBaseStruct);
399  TIM_Cmd(TIM5, ENABLE);
400 }
401 
413 
415  TIM_OCInitTypeDef TIM_OCInitStruct;
416 
417  TIM_OCInitStruct.TIM_OCMode = TIM_OCMode_PWM1;
418  TIM_OCInitStruct.TIM_OutputState = TIM_OutputState_Enable;
419  TIM_OCInitStruct.TIM_Pulse = value;
420  TIM_OCInitStruct.TIM_OCPolarity = TIM_OCPolarity_High;
421  switch (channel) {
422  case CARME_IO2_PWM0:
423  TIM_OC1Init(TIM5, &TIM_OCInitStruct);
424  TIM_OC1PreloadConfig(TIM5, TIM_OCPreload_Enable);
425  break;
426  case CARME_IO2_PWM1:
427  TIM_OC2Init(TIM5, &TIM_OCInitStruct);
428  TIM_OC2PreloadConfig(TIM5, TIM_OCPreload_Enable);
429  break;
430  case CARME_IO2_PWM2:
431  TIM_OC3Init(TIM5, &TIM_OCInitStruct);
432  TIM_OC3PreloadConfig(TIM5, TIM_OCPreload_Enable);
433  break;
434  case CARME_IO2_PWM3:
435  TIM_OC4Init(TIM5, &TIM_OCInitStruct);
436  TIM_OC4PreloadConfig(TIM5, TIM_OCPreload_Enable);
437  break;
438  default:
440  break;
441  }
442  TIM_ARRPreloadConfig(TIM5, ENABLE);
443 
444  return err;
445 }
446 
457 
460  CARME_AGPIO_PIN_21 );
461 }
462 
471 void CARME_IO2_GPIO_IN_Get(uint8_t *pStatus) {
472 
473  uint32_t agpio_state;
474  uint8_t value = 0;
475 
476  value |= (GPIO_ReadInputDataBit(GPIOG, GPIO_Pin_8) != Bit_RESET) ? 0x1 : 0;
477  value |= (GPIO_ReadInputDataBit(GPIOG, GPIO_Pin_6) != Bit_RESET) ? 0x2 : 0;
478  value |= (GPIO_ReadInputDataBit(GPIOG, GPIO_Pin_7) != Bit_RESET) ? 0x4 : 0;
479  CARME_AGPIO_Get(&agpio_state);
480  value |= (agpio_state & CARME_AGPIO_PIN_108) ? 0x8 : 0;
481  *pStatus = value;
482 }
483 
492 void CARME_IO2_GPIO_OUT_Set(uint8_t Status) {
493 
494  uint8_t i;
495  BitAction BitVal;
496 
497  for (i = 0; i < sizeof(CARME_IO2_GPIO_Out_Port_Pin) / sizeof(CARME_Port_Pin_t);
498  i++) {
499 
500  BitVal = (Status & (1 << i)) ? Bit_SET : Bit_RESET;
501  GPIO_WriteBit(CARME_IO2_GPIO_Out_Port_Pin[i].GPIOx,
502  CARME_IO2_GPIO_Out_Port_Pin[i].GPIO_Pin, BitVal);
503  }
504 }
505 
514 void CARME_IO2_OPTO_IN_Get(uint8_t *pStatus) {
515 
516  uint8_t i;
517  uint32_t BitStatus = 0;
518 
519  for (i = 0; i < sizeof(CARME_IO2_OPTO_In_Port_Pin) / sizeof(CARME_Port_Pin_t);
520  i++) {
521 
522  if (GPIO_ReadInputDataBit(CARME_IO2_OPTO_In_Port_Pin[i].GPIOx,
523  CARME_IO2_OPTO_In_Port_Pin[i].GPIO_Pin)
524  != Bit_RESET) {
525 
526  BitStatus |= (1 << i);
527  }
528  }
529  *pStatus = BitStatus;
530 }
531 
540 void CARME_IO2_OPTO_OUT_Set(uint8_t Status) {
541 
542  uint8_t i;
543  BitAction BitVal;
544 
545  for (i = 0; i < sizeof(CARME_IO2_OPTO_Out_Port_Pin) / sizeof(CARME_Port_Pin_t);
546  i++) {
547 
548  BitVal = (Status & (1 << i)) ? Bit_SET : Bit_RESET;
549  GPIO_WriteBit(CARME_IO2_OPTO_Out_Port_Pin[i].GPIOx,
550  CARME_IO2_OPTO_Out_Port_Pin[i].GPIO_Pin, BitVal);
551  }
552 }
553 
554 #ifdef __cplusplus
555 }
556 #endif /* __cplusplus */
557 
#define GPIO_AF_SPI1
AF 5 selection.
uint32_t ADC_TwoSamplingDelay
Definition: stm32f4xx_adc.h:96
#define CARME_IO2_GPIO_OUT_PIN0
Definition: carme_io2.h:84
static uint8_t CARME_IO2_ADC_Channels[]
CARME IO2 ADC channel list.
Definition: carme_io2.c:144
#define CARME_AGPIO_116
Definition: carme.h:108
uint8_t ERROR_CODES
Error variable.
Definition: carme.h:255
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.
Definition: carme_io2.c:245
static CARME_Port_Pin_t CARME_IO2_GPIO_Out_Port_Pin[]
CARME IO2 GPIO Out Port and Pin association.
Definition: carme_io2.c:118
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.
uint16_t SPI_CPOL
Definition: stm32f4xx_spi.h:65
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.
Definition: carme_io2.c:333
#define CARME_AGPIO_108
Definition: carme.h:106
#define CARME_IO2_LTC2622_CMD_WUn
Definition: carme_io2.h:92
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
Definition: carme.h:127
uint16_t SPI_DataSize
Definition: stm32f4xx_spi.h:62
#define CARME_AGPIO_115
Definition: carme.h:107
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.
#define CARME_AGPIO_97
Definition: carme.h:100
GPIOSpeed_TypeDef GPIO_Speed
void ADC_DeInit(void)
Deinitializes all ADCs peripherals registers to their default reset values.
ADC Init structure definition.
Definition: stm32f4xx_adc.h:53
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.
Definition: carme_io2.c:471
static CARME_Port_Pin_t CARME_IO2_Port_Pin[]
CARME IO2 Port and Pin association.
Definition: carme_io2.c:95
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.
Definition: carme.c:540
uint16_t SPI_CPHA
Definition: stm32f4xx_spi.h:68
static CARME_Port_Pin_t CARME_IO2_OPTO_In_Port_Pin[]
CARME IO2 OPTO In Port and Pin association.
Definition: carme_io2.c:136
void CARME_IO2_Init(void)
CARME IO2 initialization.
Definition: carme_io2.c:158
uint16_t SPI_BaudRatePrescaler
Definition: stm32f4xx_spi.h:75
void CARME_IO2_GPIO_OUT_Set(uint8_t Status)
Set the GPIO Out 0..3 value.
Definition: carme_io2.c:492
#define CARME_ERROR_IO2_PWM_WRONG_CHANNEL
Definition: carme_io2.h:82
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.
Definition: carme_io2.c:279
TIM Output Compare Init structure definition.
Definition: stm32f4xx_tim.h:84
CARME port and pin association structure.
Definition: carme.h:245
#define CARME_AGPIO_PIN_108
Definition: carme.h:115
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.
Definition: stm32f4xx_tim.h:55
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.
uint16_t SPI_NSS
Definition: stm32f4xx_spi.h:71
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.
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.
Definition: carme_io2.c:346
void CARME_AGPIO_Set(uint32_t write, uint32_t mask)
Set the AGPIO state.
Definition: carme.c:567
uint16_t SPI_Mode
Definition: stm32f4xx_spi.h:59
SPI Init structure definition.
Definition: stm32f4xx_spi.h:54
#define CARME_NO_ERROR
Definition: carme.h:135
FlagStatus ADC_GetFlagStatus(ADC_TypeDef *ADCx, uint8_t ADC_FLAG)
Checks whether the specified ADC flag is set or not.
uint16_t TIM_OCPolarity
Definition: stm32f4xx_tim.h:99
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.
Definition: stm32f4xx_adc.h:84
#define CARME_IO2_GPIO_OUT_PIN2
Definition: carme_io2.h:86
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
Definition: stm32f4xx_adc.h:75
static CARME_Port_Pin_t CARME_IO2_OPTO_Out_Port_Pin[]
CARME IO2 OPTO Out Port and Pin association.
Definition: carme_io2.c:128
void CARME_IO2_SPI_Select(CARME_IO2_SPI_CHANNEL select)
Select the peripheral SPI chip.
Definition: carme_io2.c:317
void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Enables or disables the Low Speed APB (APB1) peripheral clock.
uint32_t ADC_Resolution
Definition: stm32f4xx_adc.h:55
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
uint16_t TIM_OutputState
Definition: stm32f4xx_tim.h:89
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.
Definition: carme_io2.c:412
#define CARME_AGPIO_21
Definition: carme.h:93
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_AGPIO_22
Definition: carme.h:94
#define CARME_IO2_GPIO_OUT_PIN1
Definition: carme_io2.h:85
void CARME_AGPIO_Get(uint32_t *pStatus)
Get the AGPIO state.
Definition: carme.c:592
#define CARME_AGPIO_96
Definition: carme.h:99
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 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.
Definition: carme_io2.c:456
#define CARME_AGPIO_105
Definition: carme.h:105
CARME IO2 extension module board support package.
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
#define CARME_AGPIO_PIN_21
Definition: carme.h:128
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.