81 #include <stm32f4xx.h>
85 #define CARME_ACTIVATE_EXT_FLASH 0
90 #define CARME_GPIO_PIN_TO_MODER(GPIO_PIN) ( \
91 ((GPIO_PIN) & GPIO_Pin_0) ? GPIO_MODER_MODER0 : \
92 ((GPIO_PIN) & GPIO_Pin_1) ? GPIO_MODER_MODER1 : \
93 ((GPIO_PIN) & GPIO_Pin_2) ? GPIO_MODER_MODER2 : \
94 ((GPIO_PIN) & GPIO_Pin_3) ? GPIO_MODER_MODER3 : \
95 ((GPIO_PIN) & GPIO_Pin_4) ? GPIO_MODER_MODER4 : \
96 ((GPIO_PIN) & GPIO_Pin_5) ? GPIO_MODER_MODER5 : \
97 ((GPIO_PIN) & GPIO_Pin_6) ? GPIO_MODER_MODER6 : \
98 ((GPIO_PIN) & GPIO_Pin_7) ? GPIO_MODER_MODER7 : \
99 ((GPIO_PIN) & GPIO_Pin_8) ? GPIO_MODER_MODER8 : \
100 ((GPIO_PIN) & GPIO_Pin_9) ? GPIO_MODER_MODER9 : \
101 ((GPIO_PIN) & GPIO_Pin_10) ? GPIO_MODER_MODER10 : \
102 ((GPIO_PIN) & GPIO_Pin_11) ? GPIO_MODER_MODER11 : \
103 ((GPIO_PIN) & GPIO_Pin_12) ? GPIO_MODER_MODER12 : \
104 ((GPIO_PIN) & GPIO_Pin_13) ? GPIO_MODER_MODER13 : \
105 ((GPIO_PIN) & GPIO_Pin_14) ? GPIO_MODER_MODER14 : \
106 ((GPIO_PIN) & GPIO_Pin_15) ? GPIO_MODER_MODER15 : \
284 GPIO_InitStruct.
GPIO_PuPd = GPIO_PuPd_DOWN;
314 &FSMC_NORSRAMTimingInitStruct;
316 &FSMC_NORSRAMTimingInitStruct;
318 #if CARME_ACTIVATE_EXT_FLASH
347 FSMC_NORSRAMInitStruct.
FSMC_Bank = FSMC_Bank1_NORSRAM1;
352 FSMC_BurstAccessMode_Disable;
354 FSMC_AsynchronousWait_Disable;
356 FSMC_WaitSignalPolarity_Low;
357 FSMC_NORSRAMInitStruct.
FSMC_WrapMode = FSMC_WrapMode_Disable;
359 FSMC_WaitSignalActive_BeforeWaitState;
396 FSMC_NORSRAMInitStruct.
FSMC_Bank = FSMC_Bank1_NORSRAM2;
401 FSMC_BurstAccessMode_Disable;
403 FSMC_AsynchronousWait_Disable;
405 FSMC_WaitSignalPolarity_Low;
406 FSMC_NORSRAMInitStruct.
FSMC_WrapMode = FSMC_WrapMode_Disable;
408 FSMC_WaitSignalActive_BeforeWaitState;
444 FSMC_NORSRAMInitStruct.
FSMC_Bank = FSMC_Bank1_NORSRAM3;
449 FSMC_BurstAccessMode_Disable;
451 FSMC_AsynchronousWait_Disable;
453 FSMC_WaitSignalPolarity_Low;
454 FSMC_NORSRAMInitStruct.
FSMC_WrapMode = FSMC_WrapMode_Disable;
456 FSMC_WaitSignalActive_BeforeWaitState;
492 FSMC_NORSRAMInitStruct.
FSMC_Bank = FSMC_Bank1_NORSRAM4;
497 FSMC_BurstAccessMode_Disable;
499 FSMC_AsynchronousWait_Disable;
501 FSMC_WaitSignalPolarity_Low;
502 FSMC_NORSRAMInitStruct.
FSMC_WrapMode = FSMC_WrapMode_Disable;
504 FSMC_WaitSignalActive_BeforeWaitState;
545 for (i = 0; i < size; i++) {
546 pGPIO_InitStruct->
GPIO_Pin = pPortPinAssociation[i].GPIO_Pin;
547 pGPIO_InitStruct->
GPIO_Mode = pPortPinAssociation[i].GPIO_Mode;
548 GPIO_Init(pPortPinAssociation[i].GPIOx, pGPIO_InitStruct);
551 pPortPinAssociation[i].GPIOx,
553 pPortPinAssociation[i].GPIO_AF);
575 if (mask & (1 << i)) {
577 BitVal = (write & (1 << i)) ? Bit_SET : Bit_RESET;
579 CARME_AGPIO_Port_Pin[i].GPIO_Pin, BitVal);
595 uint32_t BitStatus = 0;
601 CARME_AGPIO_Port_Pin[i].GPIO_Pin)
605 CARME_AGPIO_Port_Pin[i].GPIO_Pin)
608 BitStatus |= (1 << i);
612 CARME_AGPIO_Port_Pin[i].GPIO_Pin)
616 CARME_AGPIO_Port_Pin[i].GPIO_Pin)
619 BitStatus |= (1 << i);
623 *pStatus = BitStatus;
void RCC_AHB3PeriphClockCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState)
Enables or disables the AHB3 peripheral clock.
static void CARME_FSMC_Init(void)
Initialization of the FSMC. This bus is used for the connection to the CarmeIO1 and CarmeIO2 module...
GPIOOType_TypeDef GPIO_OType
uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Reads the specified input port pin.
static void CARME_FSMC_GPIO_Init(void)
Initialization of the FSMC GPIO pins. This bus is used for the connection to the extension modules...
void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
Enables or disables the High Speed APB (APB2) peripheral clock.
#define CARME_GPIO_PIN_TO_MODER(GPIO_PIN)
Get the pin moder from the pin number.
void GPIO_PinAFConfig(GPIO_TypeDef *GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
Changes the mapping of the specified pin.
#define CARME_GPIO_PIN_TO_SOURCE(GPIO_PIN)
Get GPIO_PinSourcex from GPIO_Pin_x.
uint32_t FSMC_BurstAccessMode
uint32_t FSMC_DataSetupTime
GPIOSpeed_TypeDef GPIO_Speed
void CARME_LED_Red_Reset(void)
Reset the red LED on the CARME Module.
uint32_t FSMC_AsynchronousWait
uint32_t FSMC_WriteOperation
static uint8_t CARME_AGPIO_GetMode(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Get the AGPIO mode.
uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Reads the specified output data port bit.
GPIOPuPd_TypeDef GPIO_PuPd
uint32_t FSMC_WaitSignalActive
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.
void CARME_Init(void)
CARME-M4 module initialization.
FSMC NOR/SRAM Init structure definition.
void GPIO_StructInit(GPIO_InitTypeDef *GPIO_InitStruct)
Fills each GPIO_InitStruct member with its default value.
uint32_t FSMC_WaitSignalPolarity
CARME port and pin association structure.
void GPIO_WriteBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
Sets or clears the selected data port bit.
void GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_InitStruct)
Initializes the GPIOx peripheral according to the specified parameters in the GPIO_InitStruct.
uint32_t FSMC_BusTurnAroundDuration
void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef *FSMC_NORSRAMInitStruct)
Initializes the FSMC NOR/SRAM Banks according to the specified parameters in the FSMC_NORSRAMInitStru...
FSMC_NORSRAMTimingInitTypeDef * FSMC_ReadWriteTimingStruct
void CARME_LED_Green_Set(void)
Set the green LED on the CARME Module.
void RCC_AHB1PeriphClockCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
Enables or disables the AHB1 peripheral clock.
uint32_t FSMC_AddressHoldTime
GPIOMode_TypeDef GPIO_Mode
void FSMC_NORSRAMDeInit(uint32_t FSMC_Bank)
De-initializes the FSMC NOR/SRAM Banks registers to their default reset values.
GPIO Init structure definition.
void CARME_AGPIO_Set(uint32_t write, uint32_t mask)
Set the AGPIO state.
#define CARME_LED_PIN_RED
uint32_t FSMC_MemoryDataWidth
uint32_t FSMC_DataAddressMux
uint32_t FSMC_AddressSetupTime
FSMC_NORSRAMTimingInitTypeDef * FSMC_WriteTimingStruct
void CARME_LED_Red_Set(void)
Set the red LED on the CARME Module.
void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState)
Enables or disables the specified NOR/SRAM Memory Bank.
Timing parameters For NOR/SRAM Banks.
#define CARME_LED_PIN_GREEN
void CARME_AGPIO_Get(uint32_t *pStatus)
Get the AGPIO state.
static void CARME_AGPIO_Init(void)
CARME AGPIO initialization.
BitAction
GPIO Bit SET and Bit RESET enumeration.
void GPIO_DeInit(GPIO_TypeDef *GPIOx)
De-initializes the GPIOx peripheral registers to their default reset values.
uint32_t FSMC_CLKDivision
uint32_t FSMC_ExtendedMode
void CARME_LED_Green_Reset(void)
Reset the green LED on the CARME Module.
uint32_t FSMC_DataLatency
static CARME_Port_Pin_t CARME_AGPIO_Port_Pin[]
CARME AGPIO Port and Pin association.