From b2d27a1bee9595be64cf2bced59ae727ad2e1cf6 Mon Sep 17 00:00:00 2001 From: Michael Wiebusch Date: Tue, 17 Dec 2013 13:16:16 +0100 Subject: [PATCH] cleaned up project structure --- firmware/src/Makefile | 1 + firmware/src/main.c | 121 +------ firmware/src/periph_conf.c | 691 +------------------------------------ firmware/src/periph_conf.h | 391 +-------------------- 4 files changed, 21 insertions(+), 1183 deletions(-) diff --git a/firmware/src/Makefile b/firmware/src/Makefile index 69c039e..76cfe35 100644 --- a/firmware/src/Makefile +++ b/firmware/src/Makefile @@ -6,6 +6,7 @@ OBJS+=serial.o OBJS+=spi.o OBJS+=stm32f10x_it.o OBJS+=periph_conf.o +OBJS+=CB_functions.o # OBJS+=keypins.o diff --git a/firmware/src/main.c b/firmware/src/main.c index d95708b..21d458a 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -10,9 +10,10 @@ #include "stm32f10x_conf.h" // contains all std periph includes #include "core_cm3.h" #include "stm32f10x_it.h" -#include "stm32_eval.h" // remove this file !!! +#include "periph_conf.h" #include #include "newlib_stubs.c" +#include "CB_functions.h" #define UC_NO_REGS 17 @@ -37,7 +38,7 @@ void init_SPI2(void); void spi_dma_shovel(void); -void init_CB_GPIO_Outputs(void); + /* function prototypes */ void RCC_Configuration(void); @@ -45,7 +46,7 @@ void GPIO_Configuration(void); void NVIC_Configuration(void); void USART1_IRQHandler(void); void init_USART1_w_interrupt(void); -void decode_uC_reg(uint8_t addr); + // MAIN --------------------------------------------------------------------- @@ -271,66 +272,7 @@ void disable_JTAG(void) { } -void init_CB_GPIO_Outputs(void) { - - CB_GPIO_Out_Init(LED1); - CB_GPIO_Out_Init(LED2); - CB_GPIO_Out_Init(LED3); - CB_GPIO_Out_Init(LED4); - CB_GPIO_Out_Init(JTAGEN0); - CB_GPIO_Out_Init(JTAGEN1); - CB_GPIO_Out_Init(SENSOREN0); - CB_GPIO_Out_Init(SENSOREN1); - CB_GPIO_Out_Init(DISD0); - CB_GPIO_Out_Init(DISA0); - CB_GPIO_Out_Init(DISD1); - CB_GPIO_Out_Init(DISA1); - CB_GPIO_Out_Init(ENAD0); - CB_GPIO_Out_Init(ENAA0); - CB_GPIO_Out_Init(ENAD1); - CB_GPIO_Out_Init(ENAA1); -// CB_GPIO_Out_Init(OVCD_C0); //input! -// CB_GPIO_Out_Init(OVCA_C0); //input! -// CB_GPIO_Out_Init(OVCD_C1); //input! -// CB_GPIO_Out_Init(OVCA_C1); //input! - CB_GPIO_Out_Init(MUXADDR0); - CB_GPIO_Out_Init(MUXADDR1); - CB_GPIO_Out_Init(ZEROCALIB); - CB_GPIO_Out_Init(ADC_CONV0); - CB_GPIO_Out_Init(ADC_CONV1); - CB_GPIO_Out_Init(DAC_CS); - CB_GPIO_Out_Init(UC_CS); - - - CB_GPIO_Out_Hi(LED1); - CB_GPIO_Out_Lo(LED2); - CB_GPIO_Out_Lo(LED3); - CB_GPIO_Out_Lo(LED4); - CB_GPIO_Out_Hi(JTAGEN0); - CB_GPIO_Out_Hi(JTAGEN1); - CB_GPIO_Out_Hi(SENSOREN0); - CB_GPIO_Out_Hi(SENSOREN1); - CB_GPIO_Out_Lo(DISD0); - CB_GPIO_Out_Lo(DISA0); - CB_GPIO_Out_Lo(DISD1); - CB_GPIO_Out_Lo(DISA1); - CB_GPIO_Out_Hi(ENAD0); - CB_GPIO_Out_Hi(ENAA0); - CB_GPIO_Out_Hi(ENAD1); - CB_GPIO_Out_Hi(ENAA1); -// CB_GPIO_Out_Lo(OVCD_C0); //input! -// CB_GPIO_Out_Lo(OVCA_C0); //input! -// CB_GPIO_Out_Lo(OVCD_C1); //input! -// CB_GPIO_Out_Lo(OVCA_C1); //input! - CB_GPIO_Out_Lo(MUXADDR0); - CB_GPIO_Out_Lo(MUXADDR1); - CB_GPIO_Out_Lo(ZEROCALIB); - CB_GPIO_Out_Hi(ADC_CONV0); // spi nCS -> idle Hi - CB_GPIO_Out_Hi(ADC_CONV1); // spi nCS -> idle Hi - CB_GPIO_Out_Hi(DAC_CS); // spi nCS -> idle Hi - CB_GPIO_Out_Hi(UC_CS); // spi nCS -> idle Hi -} @@ -454,62 +396,9 @@ void USART1_IRQHandler(void) byte0 = data; uC_regs[addr] = ((uint16_t) byte1)<<8 | (uint16_t) byte0; byte_counter = 0; - decode_uC_reg(addr); + decode_register(addr,uC_regs); break; } } - - -void decode_uC_reg(uint8_t addr) { - - switch (addr){ - case 0x0: - uC_regs[uC_regs[addr]]++; // just for debug reasons - USART_SendData(USART1, addr); - while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); - USART_SendData(USART1, (uint8_t) (uC_regs[addr]>>8)); // upper nibble - while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); - USART_SendData(USART1, (uint8_t) (uC_regs[addr] & 0x00FF)); // lower nibble - while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); - - break; - case 0x1: - CB_GPIO_Out(ENAA0,uC_regs[addr] & 1<<5); - CB_GPIO_Out(DISA0,uC_regs[addr] & 1<<4); - CB_GPIO_Out(ENAD0,uC_regs[addr] & 1<<3); - CB_GPIO_Out(DISD0,uC_regs[addr] & 1<<2); - CB_GPIO_Out(SENSOREN0,uC_regs[addr] & 1<<1); - CB_GPIO_Out(JTAGEN0,uC_regs[addr] & 1<<0); - break; - case 0x2: - CB_GPIO_Out(ENAA1,uC_regs[addr] & 1<<5); - CB_GPIO_Out(DISA1,uC_regs[addr] & 1<<4); - CB_GPIO_Out(ENAD1,uC_regs[addr] & 1<<3); - CB_GPIO_Out(DISD1,uC_regs[addr] & 1<<2); - CB_GPIO_Out(SENSOREN1,uC_regs[addr] & 1<<1); - CB_GPIO_Out(JTAGEN1,uC_regs[addr] & 1<<0); - break; - - case 0x10: - if(uC_regs[addr] & 1<<7) { - CB_GPIO_Out(LED4,uC_regs[addr] & 1<<3); - } - if(uC_regs[addr] & 1<<6) { - CB_GPIO_Out(LED3,uC_regs[addr] & 1<<2); - } - if(uC_regs[addr] & 1<<5) { - CB_GPIO_Out(LED2,uC_regs[addr] & 1<<1); - } - if(uC_regs[addr] & 1<<4) { - CB_GPIO_Out(LED1,uC_regs[addr] & 1<<0); - } - - break; - - - } - - -} \ No newline at end of file diff --git a/firmware/src/periph_conf.c b/firmware/src/periph_conf.c index 13f4e94..21b81a1 100644 --- a/firmware/src/periph_conf.c +++ b/firmware/src/periph_conf.c @@ -1,29 +1,10 @@ -//modified by micha - /** - ****************************************************************************** - * @file stm32100e_eval.c - * @author MCD Application Team - * @version V4.5.0 - * @date 07-March-2011 - * @brief This file provides - * - set of firmware functions to manage Leds, push-button and COM ports - * - low level initialization functions for SD card (on SDIO), SPI serial - * flash (sFLASH) and temperature sensor (LM75) - * available on STM32100E-EVAL evaluation board from STMicroelectronics. - ****************************************************************************** - * @attention - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2011 STMicroelectronics

- ****************************************************************************** - */ + ******************************************************** + * + * uC periphery configuration + * + ******************************************************** + */ /* Includes ------------------------------------------------------------------*/ #include "periph_conf.h" @@ -129,82 +110,6 @@ const uint32_t CB_GPIO_CLK[27] = }; - -GPIO_TypeDef* GPIO_PORT[LEDn] = {LED1_GPIO_PORT, LED2_GPIO_PORT, LED3_GPIO_PORT, - LED4_GPIO_PORT}; -const uint16_t GPIO_PIN[LEDn] = {LED1_PIN, LED2_PIN, LED3_PIN, - LED4_PIN}; -const uint32_t GPIO_CLK[LEDn] = {LED1_GPIO_CLK, LED2_GPIO_CLK, LED3_GPIO_CLK, - LED4_GPIO_CLK}; - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {WAKEUP_BUTTON_GPIO_PORT, TAMPER_BUTTON_GPIO_PORT, - KEY_BUTTON_GPIO_PORT, RIGHT_BUTTON_GPIO_PORT, - LEFT_BUTTON_GPIO_PORT, UP_BUTTON_GPIO_PORT, - DOWN_BUTTON_GPIO_PORT, SEL_BUTTON_GPIO_PORT}; - -const uint16_t BUTTON_PIN[BUTTONn] = {WAKEUP_BUTTON_PIN, TAMPER_BUTTON_PIN, - KEY_BUTTON_PIN, RIGHT_BUTTON_PIN, - LEFT_BUTTON_PIN, UP_BUTTON_PIN, - DOWN_BUTTON_PIN, SEL_BUTTON_PIN}; - -const uint32_t BUTTON_CLK[BUTTONn] = {WAKEUP_BUTTON_GPIO_CLK, TAMPER_BUTTON_GPIO_CLK, - KEY_BUTTON_GPIO_CLK, RIGHT_BUTTON_GPIO_CLK, - LEFT_BUTTON_GPIO_CLK, UP_BUTTON_GPIO_CLK, - DOWN_BUTTON_GPIO_CLK, SEL_BUTTON_GPIO_CLK}; - -const uint16_t BUTTON_EXTI_LINE[BUTTONn] = {WAKEUP_BUTTON_EXTI_LINE, - TAMPER_BUTTON_EXTI_LINE, - KEY_BUTTON_EXTI_LINE, - RIGHT_BUTTON_EXTI_LINE, - LEFT_BUTTON_EXTI_LINE, - UP_BUTTON_EXTI_LINE, - DOWN_BUTTON_EXTI_LINE, - SEL_BUTTON_EXTI_LINE}; - -const uint16_t BUTTON_PORT_SOURCE[BUTTONn] = {WAKEUP_BUTTON_EXTI_PORT_SOURCE, - TAMPER_BUTTON_EXTI_PORT_SOURCE, - KEY_BUTTON_EXTI_PORT_SOURCE, - RIGHT_BUTTON_EXTI_PORT_SOURCE, - LEFT_BUTTON_EXTI_PORT_SOURCE, - UP_BUTTON_EXTI_PORT_SOURCE, - DOWN_BUTTON_EXTI_PORT_SOURCE, - SEL_BUTTON_EXTI_PORT_SOURCE}; - -const uint16_t BUTTON_PIN_SOURCE[BUTTONn] = {WAKEUP_BUTTON_EXTI_PIN_SOURCE, - TAMPER_BUTTON_EXTI_PIN_SOURCE, - KEY_BUTTON_EXTI_PIN_SOURCE, - RIGHT_BUTTON_EXTI_PIN_SOURCE, - LEFT_BUTTON_EXTI_PIN_SOURCE, - UP_BUTTON_EXTI_PIN_SOURCE, - DOWN_BUTTON_EXTI_PIN_SOURCE, - SEL_BUTTON_EXTI_PIN_SOURCE}; - -const uint16_t BUTTON_IRQn[BUTTONn] = {WAKEUP_BUTTON_EXTI_IRQn, TAMPER_BUTTON_EXTI_IRQn, - KEY_BUTTON_EXTI_IRQn, RIGHT_BUTTON_EXTI_IRQn, - LEFT_BUTTON_EXTI_IRQn, UP_BUTTON_EXTI_IRQn, - DOWN_BUTTON_EXTI_IRQn, SEL_BUTTON_EXTI_IRQn}; - -USART_TypeDef* COM_USART[COMn] = {EVAL_COM1, EVAL_COM2}; - -GPIO_TypeDef* COM_TX_PORT[COMn] = {EVAL_COM1_TX_GPIO_PORT, EVAL_COM2_TX_GPIO_PORT}; - -GPIO_TypeDef* COM_RX_PORT[COMn] = {EVAL_COM1_RX_GPIO_PORT, EVAL_COM2_RX_GPIO_PORT}; - -const uint32_t COM_USART_CLK[COMn] = {EVAL_COM1_CLK, EVAL_COM2_CLK}; - -const uint32_t COM_TX_PORT_CLK[COMn] = {EVAL_COM1_TX_GPIO_CLK, EVAL_COM2_TX_GPIO_CLK}; - -const uint32_t COM_RX_PORT_CLK[COMn] = {EVAL_COM1_RX_GPIO_CLK, EVAL_COM2_RX_GPIO_CLK}; - -const uint16_t COM_TX_PIN[COMn] = {EVAL_COM1_TX_PIN, EVAL_COM2_TX_PIN}; - -const uint16_t COM_RX_PIN[COMn] = {EVAL_COM1_RX_PIN, EVAL_COM2_RX_PIN}; - -DMA_InitTypeDef sEEDMA_InitStructure; - - - - void CB_GPIO_Out_Init(CB_GPIO_Pin_TypeDef Pin) { GPIO_InitTypeDef GPIO_InitStructure; @@ -221,62 +126,18 @@ void CB_GPIO_Out_Init(CB_GPIO_Pin_TypeDef Pin) } - -void STM_EVAL_LEDInit(Led_TypeDef Led) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* Enable the GPIO_LED Clock */ - RCC_APB2PeriphClockCmd(GPIO_CLK[Led], ENABLE); - - /* Configure the GPIO_LED pin */ - GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Led]; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - - GPIO_Init(GPIO_PORT[Led], &GPIO_InitStructure); -} - -/** - * @brief Turns selected LED On. - * @param Led: Specifies the Led to be set on. - * This parameter can be one of following parameters: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void STM_EVAL_LEDOn(Led_TypeDef Led) -{ - GPIO_PORT[Led]->BSRR = GPIO_PIN[Led]; -} - void CB_GPIO_Out_Hi(CB_GPIO_Pin_TypeDef Pin) { CB_GPIO_PORT[Pin]->BSRR = CB_GPIO_PIN[Pin]; } -/** - * @brief Turns selected LED Off. - * @param Led: Specifies the Led to be set off. - * This parameter can be one of following parameters: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void STM_EVAL_LEDOff(Led_TypeDef Led) -{ - GPIO_PORT[Led]->BRR = GPIO_PIN[Led]; -} void CB_GPIO_Out_Lo(CB_GPIO_Pin_TypeDef Pin) { CB_GPIO_PORT[Pin]->BRR = CB_GPIO_PIN[Pin]; } + void CB_GPIO_Out(CB_GPIO_Pin_TypeDef Pin,uint16_t state){ if(state){ CB_GPIO_Out_Hi(Pin); @@ -285,546 +146,8 @@ void CB_GPIO_Out(CB_GPIO_Pin_TypeDef Pin,uint16_t state){ } } -/** - * @brief Toggles the selected LED. - * @param Led: Specifies the Led to be toggled. - * This parameter can be one of following parameters: - * @arg LED1 - * @arg LED2 - * @arg LED3 - * @arg LED4 - * @retval None - */ -void STM_EVAL_LEDToggle(Led_TypeDef Led) -{ - GPIO_PORT[Led]->ODR ^= GPIO_PIN[Led]; -} void CB_GPIO_Out_Toggle(CB_GPIO_Pin_TypeDef Pin) { CB_GPIO_PORT[Pin]->ODR ^= CB_GPIO_PIN[Pin]; } -/** - * @brief Configures Button GPIO and EXTI Line. - * @param Button: Specifies the Button to be configured. - * This parameter can be one of following parameters: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_TAMPER: Tamper Push Button - * @arg BUTTON_KEY: Key Push Button - * @arg BUTTON_RIGHT: Joystick Right Push Button - * @arg BUTTON_LEFT: Joystick Left Push Button - * @arg BUTTON_UP: Joystick Up Push Button - * @arg BUTTON_DOWN: Joystick Down Push Button - * @arg BUTTON_SEL: Joystick Sel Push Button - * @param Button_Mode: Specifies Button mode. - * This parameter can be one of following parameters: - * @arg BUTTON_MODE_GPIO: Button will be used as simple IO - * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt - * generation capability - * @retval None - */ -void STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode) -{ - GPIO_InitTypeDef GPIO_InitStructure; - EXTI_InitTypeDef EXTI_InitStructure; - NVIC_InitTypeDef NVIC_InitStructure; - - /* Enable the BUTTON Clock */ - RCC_APB2PeriphClockCmd(BUTTON_CLK[Button] | RCC_APB2Periph_AFIO, ENABLE); - - /* Configure Button pin as input floating */ - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - GPIO_InitStructure.GPIO_Pin = BUTTON_PIN[Button]; - GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStructure); - - - if (Button_Mode == BUTTON_MODE_EXTI) - { - /* Connect Button EXTI Line to Button GPIO Pin */ - GPIO_EXTILineConfig(BUTTON_PORT_SOURCE[Button], BUTTON_PIN_SOURCE[Button]); - - /* Configure Button EXTI line */ - EXTI_InitStructure.EXTI_Line = BUTTON_EXTI_LINE[Button]; - EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; - - if(Button != BUTTON_WAKEUP) - { - EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; - } - else - { - EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; - } - EXTI_InitStructure.EXTI_LineCmd = ENABLE; - EXTI_Init(&EXTI_InitStructure); - - /* Enable and set Button EXTI Interrupt to the lowest priority */ - NVIC_InitStructure.NVIC_IRQChannel = BUTTON_IRQn[Button]; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - - NVIC_Init(&NVIC_InitStructure); - } -} - -/** - * @brief Returns the selected Button state. - * @param Button: Specifies the Button to be checked. - * This parameter can be one of following parameters: - * @arg BUTTON_WAKEUP: Wakeup Push Button - * @arg BUTTON_TAMPER: Tamper Push Button - * @arg BUTTON_KEY: Key Push Button - * @arg BUTTON_RIGHT: Joystick Right Push Button - * @arg BUTTON_LEFT: Joystick Left Push Button - * @arg BUTTON_UP: Joystick Up Push Button - * @arg BUTTON_DOWN: Joystick Down Push Button - * @arg BUTTON_SEL: Joystick Sel Push Button - * @retval The Button GPIO pin value. - */ -uint32_t STM_EVAL_PBGetState(Button_TypeDef Button) -{ - return GPIO_ReadInputDataBit(BUTTON_PORT[Button], BUTTON_PIN[Button]); -} - -/** - * @brief Configures COM port. - * @param COM: Specifies the COM port to be configured. - * This parameter can be one of following parameters: - * @arg COM1 - * @arg COM2 - * @param USART_InitStruct: pointer to a USART_InitTypeDef structure that - * contains the configuration information for the specified USART peripheral. - * @retval None - */ -void STM_EVAL_COMInit(COM_TypeDef COM, USART_InitTypeDef* USART_InitStruct) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* Enable GPIO clock */ - RCC_APB2PeriphClockCmd(COM_TX_PORT_CLK[COM] | COM_RX_PORT_CLK[COM] | RCC_APB2Periph_AFIO, ENABLE); - - /* Enable UART clock */ - if (COM == COM1) - { - RCC_APB2PeriphClockCmd(COM_USART_CLK[COM], ENABLE); - } - else - { - RCC_APB1PeriphClockCmd(COM_USART_CLK[COM], ENABLE); - } - - /* Configure USART Tx as alternate function push-pull */ - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Pin = COM_TX_PIN[COM]; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(COM_TX_PORT[COM], &GPIO_InitStructure); - - /* Configure USART Rx as input floating */ - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - GPIO_InitStructure.GPIO_Pin = COM_RX_PIN[COM]; - GPIO_Init(COM_RX_PORT[COM], &GPIO_InitStructure); - - /* USART configuration */ - USART_Init(COM_USART[COM], USART_InitStruct); - - /* Enable USART */ - USART_Cmd(COM_USART[COM], ENABLE); -} - -/** - * @brief DeInitializes the SD/SD communication. - * @param None - * @retval None - */ -void SD_LowLevel_DeInit(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - SPI_Cmd(SD_SPI, DISABLE); /*!< SD_SPI disable */ - SPI_I2S_DeInit(SD_SPI); /*!< DeInitializes the SD_SPI */ - - /*!< SD_SPI Periph clock disable */ - RCC_APB1PeriphClockCmd(SD_SPI_CLK, DISABLE); - - /*!< Configure SD_SPI pins: SCK */ - GPIO_InitStructure.GPIO_Pin = SD_SPI_SCK_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - GPIO_Init(SD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure SD_SPI pins: MISO */ - GPIO_InitStructure.GPIO_Pin = SD_SPI_MISO_PIN; - GPIO_Init(SD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure SD_SPI pins: MOSI */ - GPIO_InitStructure.GPIO_Pin = SD_SPI_MOSI_PIN; - GPIO_Init(SD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure SD_SPI_CS_PIN pin: SD Card CS pin */ - GPIO_InitStructure.GPIO_Pin = SD_CS_PIN; - GPIO_Init(SD_CS_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure SD_SPI_DETECT_PIN pin: SD Card detect pin */ - GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN; - GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure); -} - -/** - * @brief Initializes the SD_SPI and CS pins. - * @param None - * @retval None - */ -void SD_LowLevel_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - SPI_InitTypeDef SPI_InitStructure; - - /*!< SD_SPI_CS_GPIO, SD_SPI_MOSI_GPIO, SD_SPI_MISO_GPIO, SD_SPI_DETECT_GPIO - and SD_SPI_SCK_GPIO Periph clock enable */ - RCC_APB2PeriphClockCmd(SD_CS_GPIO_CLK | SD_SPI_MOSI_GPIO_CLK | SD_SPI_MISO_GPIO_CLK | - SD_SPI_SCK_GPIO_CLK | SD_DETECT_GPIO_CLK, ENABLE); - - /*!< SD_SPI Periph clock enable */ - RCC_APB1PeriphClockCmd(SD_SPI_CLK, ENABLE); - - /*!< Configure SD_SPI pins: SCK */ - GPIO_InitStructure.GPIO_Pin = SD_SPI_SCK_PIN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_Init(SD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure SD_SPI pins: MOSI */ - GPIO_InitStructure.GPIO_Pin = SD_SPI_MOSI_PIN; - GPIO_Init(SD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure SD_SPI pins: MISO */ - GPIO_InitStructure.GPIO_Pin = SD_SPI_MISO_PIN; - GPIO_Init(SD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure SD_SPI_CS_PIN pin: SD Card CS pin */ - GPIO_InitStructure.GPIO_Pin = SD_CS_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_Init(SD_CS_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure SD_SPI_DETECT_PIN pin: SD Card detect pin */ - GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; - GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure); - - /*!< SD_SPI Config */ - SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; - SPI_InitStructure.SPI_Mode = SPI_Mode_Master; - SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; - SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; - SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; - SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; - SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2; - SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; - SPI_InitStructure.SPI_CRCPolynomial = 7; - SPI_Init(SD_SPI, &SPI_InitStructure); - - SPI_Cmd(SD_SPI, ENABLE); /*!< SD_SPI enable */ -} - -/** - * @brief DeInitializes peripherals used by the I2C EEPROM driver. - * @param None - * @retval None - */ -void sEE_LowLevel_DeInit(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - NVIC_InitTypeDef NVIC_InitStructure; - - /* sEE_I2C Peripheral Disable */ - I2C_Cmd(sEE_I2C, DISABLE); - - /* sEE_I2C DeInit */ - I2C_DeInit(sEE_I2C); - - /*!< sEE_I2C Periph clock disable */ - RCC_APB1PeriphClockCmd(sEE_I2C_CLK, DISABLE); - - /*!< GPIO configuration */ - /*!< Configure sEE_I2C pins: SCL */ - GPIO_InitStructure.GPIO_Pin = sEE_I2C_SCL_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - GPIO_Init(sEE_I2C_SCL_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure sEE_I2C pins: SDA */ - GPIO_InitStructure.GPIO_Pin = sEE_I2C_SDA_PIN; - GPIO_Init(sEE_I2C_SDA_GPIO_PORT, &GPIO_InitStructure); - - /* Configure and enable I2C DMA TX Channel interrupt */ - NVIC_InitStructure.NVIC_IRQChannel = sEE_I2C_DMA_TX_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = sEE_I2C_DMA_PREPRIO; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = sEE_I2C_DMA_SUBPRIO; - NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE; - NVIC_Init(&NVIC_InitStructure); - - /* Configure and enable I2C DMA RX Channel interrupt */ - NVIC_InitStructure.NVIC_IRQChannel = sEE_I2C_DMA_RX_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = sEE_I2C_DMA_PREPRIO; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = sEE_I2C_DMA_SUBPRIO; - NVIC_Init(&NVIC_InitStructure); - - /* Disable and Deinitialize the DMA channels */ - DMA_Cmd(sEE_I2C_DMA_CHANNEL_TX, DISABLE); - DMA_Cmd(sEE_I2C_DMA_CHANNEL_RX, DISABLE); - DMA_DeInit(sEE_I2C_DMA_CHANNEL_TX); - DMA_DeInit(sEE_I2C_DMA_CHANNEL_RX); -} - -/** - * @brief Initializes peripherals used by the I2C EEPROM driver. - * @param None - * @retval None - */ -void sEE_LowLevel_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - NVIC_InitTypeDef NVIC_InitStructure; - - /*!< sEE_I2C_SCL_GPIO_CLK and sEE_I2C_SDA_GPIO_CLK Periph clock enable */ - RCC_APB2PeriphClockCmd(sEE_I2C_SCL_GPIO_CLK | sEE_I2C_SDA_GPIO_CLK, ENABLE); - - /*!< sEE_I2C Periph clock enable */ - RCC_APB1PeriphClockCmd(sEE_I2C_CLK, ENABLE); - - /*!< GPIO configuration */ - /*!< Configure sEE_I2C pins: SCL */ - GPIO_InitStructure.GPIO_Pin = sEE_I2C_SCL_PIN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD; - GPIO_Init(sEE_I2C_SCL_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure sEE_I2C pins: SDA */ - GPIO_InitStructure.GPIO_Pin = sEE_I2C_SDA_PIN; - GPIO_Init(sEE_I2C_SDA_GPIO_PORT, &GPIO_InitStructure); - - /* Configure and enable I2C DMA TX Channel interrupt */ - NVIC_InitStructure.NVIC_IRQChannel = sEE_I2C_DMA_TX_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = sEE_I2C_DMA_PREPRIO; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = sEE_I2C_DMA_SUBPRIO; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_Init(&NVIC_InitStructure); - - /* Configure and enable I2C DMA RX Channel interrupt */ - NVIC_InitStructure.NVIC_IRQChannel = sEE_I2C_DMA_RX_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = sEE_I2C_DMA_PREPRIO; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = sEE_I2C_DMA_SUBPRIO; - NVIC_Init(&NVIC_InitStructure); - - /*!< I2C DMA TX and RX channels configuration */ - /* Enable the DMA clock */ - RCC_AHBPeriphClockCmd(sEE_I2C_DMA_CLK, ENABLE); - - /* I2C TX DMA Channel configuration */ - DMA_DeInit(sEE_I2C_DMA_CHANNEL_TX); - sEEDMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)sEE_I2C_DR_Address; - sEEDMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)0; /* This parameter will be configured durig communication */ - sEEDMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; /* This parameter will be configured durig communication */ - sEEDMA_InitStructure.DMA_BufferSize = 0xFFFF; /* This parameter will be configured durig communication */ - sEEDMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; - sEEDMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; - sEEDMA_InitStructure.DMA_PeripheralDataSize = DMA_MemoryDataSize_Byte; - sEEDMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; - sEEDMA_InitStructure.DMA_Mode = DMA_Mode_Normal; - sEEDMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; - sEEDMA_InitStructure.DMA_M2M = DMA_M2M_Disable; - DMA_Init(sEE_I2C_DMA_CHANNEL_TX, &sEEDMA_InitStructure); - - /* I2C RX DMA Channel configuration */ - DMA_DeInit(sEE_I2C_DMA_CHANNEL_RX); - DMA_Init(sEE_I2C_DMA_CHANNEL_RX, &sEEDMA_InitStructure); - - /* Enable the DMA Channels Interrupts */ - DMA_ITConfig(sEE_I2C_DMA_CHANNEL_TX, DMA_IT_TC, ENABLE); - DMA_ITConfig(sEE_I2C_DMA_CHANNEL_RX, DMA_IT_TC, ENABLE); -} - -/** - * @brief Initializes DMA channel used by the I2C EEPROM driver. - * @param None - * @retval None - */ -void sEE_LowLevel_DMAConfig(uint32_t pBuffer, uint32_t BufferSize, uint32_t Direction) -{ - /* Initialize the DMA with the new parameters */ - if (Direction == sEE_DIRECTION_TX) - { - /* Configure the DMA Tx Channel with the buffer address and the buffer size */ - sEEDMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)pBuffer; - sEEDMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; - sEEDMA_InitStructure.DMA_BufferSize = (uint32_t)BufferSize; - DMA_Init(sEE_I2C_DMA_CHANNEL_TX, &sEEDMA_InitStructure); - } - else - { - /* Configure the DMA Rx Channel with the buffer address and the buffer size */ - sEEDMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)pBuffer; - sEEDMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; - sEEDMA_InitStructure.DMA_BufferSize = (uint32_t)BufferSize; - DMA_Init(sEE_I2C_DMA_CHANNEL_RX, &sEEDMA_InitStructure); - } -} - -/** - * @brief DeInitializes the peripherals used by the SPI FLASH driver. - * @param None - * @retval None - */ -void sFLASH_LowLevel_DeInit(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /*!< Disable the sFLASH_SPI */ - SPI_Cmd(sFLASH_SPI, DISABLE); - - /*!< DeInitializes the sFLASH_SPI */ - SPI_I2S_DeInit(sFLASH_SPI); - - /*!< sFLASH_SPI Periph clock disable */ - RCC_APB2PeriphClockCmd(sFLASH_SPI_CLK, DISABLE); - - /*!< Configure sFLASH_SPI pins: SCK */ - GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_SCK_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - GPIO_Init(sFLASH_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure sFLASH_SPI pins: MISO */ - GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MISO_PIN; - GPIO_Init(sFLASH_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure sFLASH_SPI pins: MOSI */ - GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MOSI_PIN; - GPIO_Init(sFLASH_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure sFLASH_CS_PIN pin: sFLASH Card CS pin */ - GPIO_InitStructure.GPIO_Pin = sFLASH_CS_PIN; - GPIO_Init(sFLASH_CS_GPIO_PORT, &GPIO_InitStructure); -} - -/** - * @brief Initializes the peripherals used by the SPI FLASH driver. - * @param None - * @retval None - */ -void sFLASH_LowLevel_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /*!< sFLASH_SPI_CS_GPIO, sFLASH_SPI_MOSI_GPIO, sFLASH_SPI_MISO_GPIO - and sFLASH_SPI_SCK_GPIO Periph clock enable */ - RCC_APB2PeriphClockCmd(sFLASH_CS_GPIO_CLK | sFLASH_SPI_MOSI_GPIO_CLK | sFLASH_SPI_MISO_GPIO_CLK | - sFLASH_SPI_SCK_GPIO_CLK, ENABLE); - - /*!< sFLASH_SPI Periph clock enable */ - RCC_APB2PeriphClockCmd(sFLASH_SPI_CLK, ENABLE); - - /*!< Configure sFLASH_SPI pins: SCK */ - GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_SCK_PIN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_Init(sFLASH_SPI_SCK_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure sFLASH_SPI pins: MOSI */ - GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MOSI_PIN; - GPIO_Init(sFLASH_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure sFLASH_SPI pins: MISO */ - GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MISO_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - GPIO_Init(sFLASH_SPI_MISO_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure sFLASH_CS_PIN pin: sFLASH Card CS pin */ - GPIO_InitStructure.GPIO_Pin = sFLASH_CS_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_Init(sFLASH_CS_GPIO_PORT, &GPIO_InitStructure); -} - -/** - * @brief DeInitializes the LM75_I2C. - * @param None - * @retval None - */ -void LM75_LowLevel_DeInit(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /*!< Disable LM75_I2C */ - I2C_Cmd(LM75_I2C, DISABLE); - /*!< DeInitializes the LM75_I2C */ - I2C_DeInit(LM75_I2C); - - /*!< LM75_I2C Periph clock disable */ - RCC_APB1PeriphClockCmd(LM75_I2C_CLK, DISABLE); - - /*!< Configure LM75_I2C pins: SCL */ - GPIO_InitStructure.GPIO_Pin = LM75_I2C_SCL_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - GPIO_Init(LM75_I2C_SCL_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure LM75_I2C pins: SDA */ - GPIO_InitStructure.GPIO_Pin = LM75_I2C_SDA_PIN; - GPIO_Init(LM75_I2C_SDA_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure LM75_I2C pin: SMBUS ALERT */ - GPIO_InitStructure.GPIO_Pin = LM75_I2C_SMBUSALERT_PIN; - GPIO_Init(LM75_I2C_SMBUSALERT_GPIO_PORT, &GPIO_InitStructure); -} - -/** - * @brief Initializes the LM75_I2C.. - * @param None - * @retval None - */ -void LM75_LowLevel_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /*!< LM75_I2C Periph clock enable */ - RCC_APB1PeriphClockCmd(LM75_I2C_CLK, ENABLE); - - /*!< LM75_I2C_SCL_GPIO_CLK, LM75_I2C_SDA_GPIO_CLK - and LM75_I2C_SMBUSALERT_GPIO_CLK Periph clock enable */ - RCC_APB2PeriphClockCmd(LM75_I2C_SCL_GPIO_CLK | LM75_I2C_SDA_GPIO_CLK | - LM75_I2C_SMBUSALERT_GPIO_CLK, ENABLE); - - /*!< Configure LM75_I2C pins: SCL */ - GPIO_InitStructure.GPIO_Pin = LM75_I2C_SCL_PIN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD; - GPIO_Init(LM75_I2C_SCL_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure LM75_I2C pins: SDA */ - GPIO_InitStructure.GPIO_Pin = LM75_I2C_SDA_PIN; - GPIO_Init(LM75_I2C_SDA_GPIO_PORT, &GPIO_InitStructure); - - /*!< Configure LM75_I2C pin: SMBUS ALERT */ - GPIO_InitStructure.GPIO_Pin = LM75_I2C_SMBUSALERT_PIN; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; - GPIO_Init(LM75_I2C_SMBUSALERT_GPIO_PORT, &GPIO_InitStructure); -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/firmware/src/periph_conf.h b/firmware/src/periph_conf.h index 0cb66df..a0c03bc 100644 --- a/firmware/src/periph_conf.h +++ b/firmware/src/periph_conf.h @@ -1,74 +1,16 @@ -// modified by micha - - -// what works? -// LED functions! - /** - ****************************************************************************** - * @file stm32100e_eval.h - * @author MCD Application Team - * @version V4.5.0 - * @date 07-March-2011 - * @brief This file contains definitions for STM32100E_EVAL's Leds, push-buttons - * COM ports, sFLASH (on SPI) and Temperature Sensor LM75 (on I2C) - * hardware resources. - ****************************************************************************** - * @attention - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2011 STMicroelectronics

- ****************************************************************************** - */ + ******************************************************** + * + * uC periphery configuration (headers) + * + ******************************************************** + */ -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32100E_EVAL_H -#define __STM32100E_EVAL_H - -#ifdef __cplusplus - extern "C" { -#endif /* Includes ------------------------------------------------------------------*/ #include "stm32f10x_conf.h" -#include "stm32_eval.h" -/** @addtogroup Utilities - * @{ - */ - -/** @addtogroup STM32_EVAL - * @{ - */ - -/** @addtogroup STM32100E_EVAL - * @{ - */ - -/** @addtogroup STM32100E_EVAL_LOW_LEVEL - * @{ - */ - -/** @defgroup STM32100E_EVAL_LOW_LEVEL_Exported_Types - * @{ - */ -/** - * @} - */ -/** @defgroup STM32100E_EVAL_LOW_LEVEL_Exported_Constants - * @{ - */ -/** @addtogroup STM32100E_EVAL_LOW_LEVEL_LED - * @{ - */ -#define LEDn 4 #define LED1_PIN GPIO_Pin_9 #define LED1_GPIO_PORT GPIOC @@ -125,11 +67,11 @@ #define ENAD0_PIN GPIO_Pin_3 #define ENAD0_GPIO_PORT GPIOC #define ENAD0_GPIO_CLK RCC_APB2Periph_GPIOC -//not working + #define ENAA0_PIN GPIO_Pin_5 #define ENAA0_GPIO_PORT GPIOC #define ENAA0_GPIO_CLK RCC_APB2Periph_GPIOC -// not working + #define ENAD1_PIN GPIO_Pin_0 #define ENAD1_GPIO_PORT GPIOC #define ENAD1_GPIO_CLK RCC_APB2Periph_GPIOC @@ -224,325 +166,8 @@ typedef enum - - - -/** - * @} - */ - -/** @addtogroup STM32100E_EVAL_LOW_LEVEL_BUTTON - * @{ - */ -#define BUTTONn 8 - -/** - * @brief Wakeup push-button - */ -#define WAKEUP_BUTTON_PIN GPIO_Pin_0 -#define WAKEUP_BUTTON_GPIO_PORT GPIOA -#define WAKEUP_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOA -#define WAKEUP_BUTTON_EXTI_LINE EXTI_Line0 -#define WAKEUP_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOA -#define WAKEUP_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource0 -#define WAKEUP_BUTTON_EXTI_IRQn EXTI0_IRQn -/** - * @brief Tamper push-button - */ -#define TAMPER_BUTTON_PIN GPIO_Pin_13 -#define TAMPER_BUTTON_GPIO_PORT GPIOC -#define TAMPER_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOC -#define TAMPER_BUTTON_EXTI_LINE EXTI_Line13 -#define TAMPER_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOC -#define TAMPER_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource13 -#define TAMPER_BUTTON_EXTI_IRQn EXTI15_10_IRQn -/** - * @brief Key push-button - */ -#define KEY_BUTTON_PIN GPIO_Pin_8 -#define KEY_BUTTON_GPIO_PORT GPIOG -#define KEY_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOG -#define KEY_BUTTON_EXTI_LINE EXTI_Line8 -#define KEY_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOG -#define KEY_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource8 -#define KEY_BUTTON_EXTI_IRQn EXTI9_5_IRQn -/** - * @brief Joystick Right push-button - */ -#define RIGHT_BUTTON_PIN GPIO_Pin_13 -#define RIGHT_BUTTON_GPIO_PORT GPIOG -#define RIGHT_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOG -#define RIGHT_BUTTON_EXTI_LINE EXTI_Line13 -#define RIGHT_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOG -#define RIGHT_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource13 -#define RIGHT_BUTTON_EXTI_IRQn EXTI15_10_IRQn -/** - * @brief Joystick Left push-button - */ -#define LEFT_BUTTON_PIN GPIO_Pin_14 -#define LEFT_BUTTON_GPIO_PORT GPIOG -#define LEFT_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOG -#define LEFT_BUTTON_EXTI_LINE EXTI_Line14 -#define LEFT_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOG -#define LEFT_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource14 -#define LEFT_BUTTON_EXTI_IRQn EXTI15_10_IRQn -/** - * @brief Joystick Up push-button - */ -#define UP_BUTTON_PIN GPIO_Pin_15 -#define UP_BUTTON_GPIO_PORT GPIOG -#define UP_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOG -#define UP_BUTTON_EXTI_LINE EXTI_Line15 -#define UP_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOG -#define UP_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource15 -#define UP_BUTTON_EXTI_IRQn EXTI15_10_IRQn -/** - * @brief Joystick Down push-button - */ -#define DOWN_BUTTON_PIN GPIO_Pin_11 -#define DOWN_BUTTON_GPIO_PORT GPIOG -#define DOWN_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOG -#define DOWN_BUTTON_EXTI_LINE EXTI_Line11 -#define DOWN_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOG -#define DOWN_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource11 -#define DOWN_BUTTON_EXTI_IRQn EXTI15_10_IRQn -/** - * @brief Joystick Sel push-button - */ -#define SEL_BUTTON_PIN GPIO_Pin_7 -#define SEL_BUTTON_GPIO_PORT GPIOG -#define SEL_BUTTON_GPIO_CLK RCC_APB2Periph_GPIOG -#define SEL_BUTTON_EXTI_LINE EXTI_Line7 -#define SEL_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOG -#define SEL_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource7 -#define SEL_BUTTON_EXTI_IRQn EXTI9_5_IRQn -/** - * @} - */ - -/** @addtogroup STM32100E_EVAL_LOW_LEVEL_COM - * @{ - */ -#define COMn 2 - -/** - * @brief Definition for COM port1, connected to USART1 - */ -#define EVAL_COM1 USART1 -#define EVAL_COM1_CLK RCC_APB2Periph_USART1 -#define EVAL_COM1_TX_PIN GPIO_Pin_9 -#define EVAL_COM1_TX_GPIO_PORT GPIOA -#define EVAL_COM1_TX_GPIO_CLK RCC_APB2Periph_GPIOA -#define EVAL_COM1_RX_PIN GPIO_Pin_10 -#define EVAL_COM1_RX_GPIO_PORT GPIOA -#define EVAL_COM1_RX_GPIO_CLK RCC_APB2Periph_GPIOA -#define EVAL_COM1_IRQn USART1_IRQn - -/** - * @brief Definition for COM port2, connected to USART2 - */ -#define EVAL_COM2 USART2 -#define EVAL_COM2_CLK RCC_APB1Periph_USART2 -#define EVAL_COM2_TX_PIN GPIO_Pin_2 -#define EVAL_COM2_TX_GPIO_PORT GPIOA -#define EVAL_COM2_TX_GPIO_CLK RCC_APB2Periph_GPIOA -#define EVAL_COM2_RX_PIN GPIO_Pin_3 -#define EVAL_COM2_RX_GPIO_PORT GPIOA -#define EVAL_COM2_RX_GPIO_CLK RCC_APB2Periph_GPIOA -#define EVAL_COM2_IRQn USART2_IRQn - -/** - * @} - */ - -/** @addtogroup STM32100E_EVAL_LOW_LEVEL_SD_FLASH - * @{ - */ -/** - * @brief SD SPI Interface pins - */ -#define SD_SPI SPI2 -#define SD_SPI_CLK RCC_APB1Periph_SPI2 -#define SD_SPI_SCK_PIN GPIO_Pin_13 /* PC.13 */ -#define SD_SPI_SCK_GPIO_PORT GPIOB /* GPIOB */ -#define SD_SPI_SCK_GPIO_CLK RCC_APB2Periph_GPIOB -#define SD_SPI_MISO_PIN GPIO_Pin_14 /* PC.14 */ -#define SD_SPI_MISO_GPIO_PORT GPIOB /* GPIOB */ -#define SD_SPI_MISO_GPIO_CLK RCC_APB2Periph_GPIOB -#define SD_SPI_MOSI_PIN GPIO_Pin_15 /* PB.15 */ -#define SD_SPI_MOSI_GPIO_PORT GPIOB /* GPIOB */ -#define SD_SPI_MOSI_GPIO_CLK RCC_APB2Periph_GPIOB -#define SD_CS_PIN GPIO_Pin_6 /* PG.06 */ -#define SD_CS_GPIO_PORT GPIOG /* GPIOG */ -#define SD_CS_GPIO_CLK RCC_APB2Periph_GPIOG -#define SD_DETECT_PIN GPIO_Pin_11 /* PF.11 */ -#define SD_DETECT_GPIO_PORT GPIOF /* GPIOF */ -#define SD_DETECT_GPIO_CLK RCC_APB2Periph_GPIOF - -/** - * @} - */ - -/** @addtogroup STM3210C_EVAL_LOW_LEVEL_I2C_EE - * @{ - */ -/** - * @brief I2C EEPROM Interface pins - */ -#define sEE_I2C I2C2 -#define sEE_I2C_CLK RCC_APB1Periph_I2C2 -#define sEE_I2C_SCL_PIN GPIO_Pin_10 /* PB.10 */ -#define sEE_I2C_SCL_GPIO_PORT GPIOB /* GPIOB */ -#define sEE_I2C_SCL_GPIO_CLK RCC_APB2Periph_GPIOB -#define sEE_I2C_SDA_PIN GPIO_Pin_11 /* PB.11 */ -#define sEE_I2C_SDA_GPIO_PORT GPIOB /* GPIOB */ -#define sEE_I2C_SDA_GPIO_CLK RCC_APB2Periph_GPIOB -#define sEE_M24C64_32 - -#define sEE_I2C_DMA DMA1 -#define sEE_I2C_DMA_CHANNEL_TX DMA1_Channel4 -#define sEE_I2C_DMA_CHANNEL_RX DMA1_Channel5 -#define sEE_I2C_DMA_FLAG_TX_TC DMA1_IT_TC4 -#define sEE_I2C_DMA_FLAG_TX_GL DMA1_IT_GL4 -#define sEE_I2C_DMA_FLAG_RX_TC DMA1_IT_TC5 -#define sEE_I2C_DMA_FLAG_RX_GL DMA1_IT_GL5 -#define sEE_I2C_DMA_CLK RCC_AHBPeriph_DMA1 -#define sEE_I2C_DR_Address ((uint32_t)0x40005810) -#define sEE_USE_DMA - -#define sEE_I2C_DMA_TX_IRQn DMA1_Channel4_IRQn -#define sEE_I2C_DMA_RX_IRQn DMA1_Channel5_IRQn -#define sEE_I2C_DMA_TX_IRQHandler DMA1_Channel4_IRQHandler -#define sEE_I2C_DMA_RX_IRQHandler DMA1_Channel5_IRQHandler -#define sEE_I2C_DMA_PREPRIO 0 -#define sEE_I2C_DMA_SUBPRIO 0 - -#define sEE_DIRECTION_TX 0 -#define sEE_DIRECTION_RX 1 - -/* Time constant for the delay caclulation allowing to have a millisecond - incrementing counter. This value should be equal to (System Clock / 1000). - ie. if system clock = 24MHz then sEE_TIME_CONST should be 24. */ -#define sEE_TIME_CONST 24 - -/** - * @} - */ - -/** @addtogroup STM32100E_EVAL_LOW_LEVEL_M25P_FLASH_SPI - * @{ - */ -/** - * @brief M25P FLASH SPI Interface pins - */ -#define sFLASH_SPI SPI1 -#define sFLASH_SPI_CLK RCC_APB2Periph_SPI1 -#define sFLASH_SPI_SCK_PIN GPIO_Pin_5 /* PA.05 */ -#define sFLASH_SPI_SCK_GPIO_PORT GPIOA /* GPIOA */ -#define sFLASH_SPI_SCK_GPIO_CLK RCC_APB2Periph_GPIOA -#define sFLASH_SPI_MISO_PIN GPIO_Pin_6 /* PA.06 */ -#define sFLASH_SPI_MISO_GPIO_PORT GPIOA /* GPIOA */ -#define sFLASH_SPI_MISO_GPIO_CLK RCC_APB2Periph_GPIOA -#define sFLASH_SPI_MOSI_PIN GPIO_Pin_7 /* PA.07 */ -#define sFLASH_SPI_MOSI_GPIO_PORT GPIOA /* GPIOA */ -#define sFLASH_SPI_MOSI_GPIO_CLK RCC_APB2Periph_GPIOA -#define sFLASH_CS_PIN GPIO_Pin_6 /* PE.06 */ -#define sFLASH_CS_GPIO_PORT GPIOE /* GPIOE */ -#define sFLASH_CS_GPIO_CLK RCC_APB2Periph_GPIOE - -/** - * @} - */ - - -/** @addtogroup STM32100E_EVAL_LOW_LEVEL_TSENSOR_I2C - * @{ - */ -/** - * @brief LM75 Temperature Sensor I2C Interface pins - */ -#define LM75_I2C I2C2 -#define LM75_I2C_CLK RCC_APB1Periph_I2C2 -#define LM75_I2C_SCL_PIN GPIO_Pin_10 /* PB.10 */ -#define LM75_I2C_SCL_GPIO_PORT GPIOB /* GPIOB */ -#define LM75_I2C_SCL_GPIO_CLK RCC_APB2Periph_GPIOB -#define LM75_I2C_SDA_PIN GPIO_Pin_11 /* PB.11 */ -#define LM75_I2C_SDA_GPIO_PORT GPIOB /* GPIOB */ -#define LM75_I2C_SDA_GPIO_CLK RCC_APB2Periph_GPIOB -#define LM75_I2C_SMBUSALERT_PIN GPIO_Pin_12 /* PB.12 */ -#define LM75_I2C_SMBUSALERT_GPIO_PORT GPIOB /* GPIOB */ -#define LM75_I2C_SMBUSALERT_GPIO_CLK RCC_APB2Periph_GPIOB -#define LM75_I2C_DR ((uint32_t)0x40005810) - -#define LM75_DMA_CLK RCC_AHBPeriph_DMA1 -#define LM75_DMA_TX_CHANNEL DMA1_Channel4 -#define LM75_DMA_RX_CHANNEL DMA1_Channel5 -#define LM75_DMA_TX_TCFLAG DMA1_FLAG_TC4 -#define LM75_DMA_RX_TCFLAG DMA1_FLAG_TC5 - -/** - * @} - */ - -/** - * @} - */ - -/** @defgroup STM32100E_EVAL_LOW_LEVEL_Exported_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32100E_EVAL_LOW_LEVEL_Exported_Functions - * @{ - */ -void STM_EVAL_LEDInit(Led_TypeDef Led); -void STM_EVAL_LEDOn(Led_TypeDef Led); -void STM_EVAL_LEDOff(Led_TypeDef Led); -void STM_EVAL_LEDToggle(Led_TypeDef Led); - void CB_GPIO_Out_Init(CB_GPIO_Pin_TypeDef Pin); void CB_GPIO_Out_Hi(CB_GPIO_Pin_TypeDef Pin); void CB_GPIO_Out_Lo(CB_GPIO_Pin_TypeDef Pin); void CB_GPIO_Out_Toggle(CB_GPIO_Pin_TypeDef Pin); void CB_GPIO_Out(CB_GPIO_Pin_TypeDef Pin,uint16_t state); - -void STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode); -uint32_t STM_EVAL_PBGetState(Button_TypeDef Button); -void STM_EVAL_COMInit(COM_TypeDef COM, USART_InitTypeDef* USART_InitStruct); -void SD_LowLevel_DeInit(void); -void SD_LowLevel_Init(void); -void sEE_LowLevel_DeInit(void); -void sEE_LowLevel_Init(void); -void sEE_LowLevel_DMAConfig(uint32_t pBuffer, uint32_t BufferSize, uint32_t Direction); -void sFLASH_LowLevel_DeInit(void); -void sFLASH_LowLevel_Init(void); -void LM75_LowLevel_DeInit(void); -void LM75_LowLevel_Init(void); -/** - * @} - */ -#ifdef __cplusplus -} -#endif - -#endif /* __STM32100E_EVAL_H */ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ -- 2.43.0