# HG changeset patch # User Ethan Zonca # Date 2015-01-03 00:01:13 # Node ID 81af28f44609a954e5589e6ab907341222ee7c0a # Parent 425d70b8073e1199ae58a3a0bdc53481e1700e5c Cleanup and includes fixes diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -1,5 +1,4 @@ #include "main.h" -#include "stm32l100c_discovery.h" #include "ssd1306.h" #include "config.h" #include "eeprom_min.h" @@ -7,11 +6,11 @@ #include "spi.h" // USB includes -#include "hw_config.h" -#include "usb_lib.h" -#include "usb_desc.h" -#include "usb_pwr.h" -#include "stringhelpers.h" +//#include "hw_config.h" +//#include "usb_lib.h" +//#include "usb_desc.h" +//#include "usb_pwr.h" +//#include "stringhelpers.h" // TODO: Grab buttonpresses with interrupts @@ -102,6 +101,7 @@ int main(void) ssd1306_clearscreen(); // Check for problems on startup + uint8_t clock_fail = 0; // FIXME implement in system if(clock_fail) { //ssd1306_DrawStringBig("ERROR: Check Xtal", 2, 0); ssd1306_DrawStringBig("NO XTAL", 2, 0); @@ -111,9 +111,9 @@ int main(void) // Init USB //Set_System(); // hw_config.h - Set_USBClock(); - USB_Interrupts_Config(); - USB_Init(); + //Set_USBClock(); + //SB_Interrupts_Config(); + //SB_Init(); //SYSCFG_USBPuCmd(ENABLE); //PowerOn(); diff --git a/main.h b/main.h --- a/main.h +++ b/main.h @@ -1,8 +1,7 @@ #ifndef __MAIN_H #define __MAIN_H -#include "stm32l1xx.h" -#include "stm32l100c_discovery.h" +#include "stm32f0xx.h" void TimingDelay_Decrement(void); void delay(__IO uint32_t nTime); diff --git a/stm32l100c_discovery.c b/stm32l100c_discovery.c deleted file mode 100644 --- a/stm32l100c_discovery.c +++ /dev/null @@ -1,153 +0,0 @@ -#include "stm32l100c_discovery.h" - -GPIO_TypeDef* GPIO_PORT[LEDn] = {LED3_GPIO_PORT, LED4_GPIO_PORT}; -const uint16_t GPIO_PIN[LEDn] = {LED3_PIN, LED4_PIN}; -const uint32_t GPIO_CLK[LEDn] = {LED3_GPIO_CLK, LED4_GPIO_CLK}; - -GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {USER_BUTTON_GPIO_PORT}; - -const uint16_t BUTTON_PIN[BUTTONn] = {USER_BUTTON_PIN}; - -const uint32_t BUTTON_CLK[BUTTONn] = {USER_BUTTON_GPIO_CLK}; - -const uint16_t BUTTON_EXTI_LINE[BUTTONn] = {USER_BUTTON_EXTI_LINE}; - -const uint16_t BUTTON_PORT_SOURCE[BUTTONn] = {USER_BUTTON_EXTI_PORT_SOURCE}; - -const uint16_t BUTTON_PIN_SOURCE[BUTTONn] = {USER_BUTTON_EXTI_PIN_SOURCE}; - -const uint16_t BUTTON_IRQn[BUTTONn] = {USER_BUTTON_EXTI_IRQn}; - -/** - * @brief Configures LED GPIO. - * @param Led: Specifies the Led to be configured. - * This parameter can be one of following parameters: - * @arg LED3 - * @arg LED4 - * @retval None - */ -void STM_EVAL_LEDInit(Led_TypeDef Led) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - /* Enable the GPIO_LED Clock */ - RCC_AHBPeriphClockCmd(GPIO_CLK[Led], ENABLE); - - /* Configure the GPIO_LED pin */ - GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Led]; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz; - 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 LED3 - * @arg LED4 - * @retval None - */ -void STM_EVAL_LEDOn(Led_TypeDef Led) -{ - GPIO_PORT[Led]->BSRRL = GPIO_PIN[Led]; -} - -/** - * @brief Turns selected LED Off. - * @param Led: Specifies the Led to be set off. - * This parameter can be one of following parameters: - * @arg LED3 - * @arg LED4 - * @retval None - */ -void STM_EVAL_LEDOff(Led_TypeDef Led) -{ - GPIO_PORT[Led]->BSRRH = GPIO_PIN[Led]; -} - -/** - * @brief Toggles the selected LED. - * @param Led: Specifies the Led to be toggled. - * This parameter can be one of following parameters: - * @arg LED3 - * @arg LED4 - * @retval None - */ -void STM_EVAL_LEDToggle(Led_TypeDef Led) -{ - GPIO_PORT[Led]->ODR ^= GPIO_PIN[Led]; -} - -/** - * @brief Configures Button GPIO and EXTI Line. - * @param Button: Specifies the Button to be configured. - * This parameter can be: - * @arg BUTTON_USER: User 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_AHBPeriphClockCmd(BUTTON_CLK[Button], ENABLE); - RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); - - /* Configure Button pin as input */ - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - 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 */ - SYSCFG_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_USER) - { - EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; - } - else - { - EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; - } - 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_USER: User Push Button - * @retval The Button GPIO pin value. - */ -uint32_t STM_EVAL_PBGetState(Button_TypeDef Button) -{ - /* There is no Wakeup button on STM32f0-Discovery Kit */ - return GPIO_ReadInputDataBit(BUTTON_PORT[Button], BUTTON_PIN[Button]); -} - diff --git a/stm32l100c_discovery.h b/stm32l100c_discovery.h deleted file mode 100644 --- a/stm32l100c_discovery.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __STM32L100C_DISCOVERY_H -#define __STM32L100C_DISCOVERY_H - -#ifdef __cplusplus - extern "C" { -#endif - -#include "stm32l1xx.h" - -typedef enum -{ - LED3 = 0, - LED4 = 1 -} Led_TypeDef; - -typedef enum -{ - BUTTON_USER = 0, -} Button_TypeDef; - -typedef enum -{ - BUTTON_MODE_GPIO = 0, - BUTTON_MODE_EXTI = 1 -} ButtonMode_TypeDef; - -#define LEDn 2 - -#define LED3_PIN GPIO_Pin_9 -#define LED3_GPIO_PORT GPIOB -#define LED3_GPIO_CLK RCC_AHBPeriph_GPIOB - -#define LED4_PIN GPIO_Pin_15 -#define LED4_GPIO_PORT GPIOA -#define LED4_GPIO_CLK RCC_AHBPeriph_GPIOA - -#define BUTTONn 1 - -#define USER_BUTTON_PIN GPIO_Pin_3 -#define USER_BUTTON_GPIO_PORT GPIOB -#define USER_BUTTON_GPIO_CLK RCC_AHBPeriph_GPIOB -#define USER_BUTTON_EXTI_LINE EXTI_Line0 -#define USER_BUTTON_EXTI_PORT_SOURCE EXTI_PortSourceGPIOB -#define USER_BUTTON_EXTI_PIN_SOURCE EXTI_PinSource0 -#define USER_BUTTON_EXTI_IRQn EXTI0_IRQn - -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 STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode); -uint32_t STM_EVAL_PBGetState(Button_TypeDef Button); - - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32L100C_DISCOVERY_H */ diff --git a/stm32l1xx_conf.h b/stm32l1xx_conf.h deleted file mode 100644 --- a/stm32l1xx_conf.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef __STM32L1xx_CONF_H -#define __STM32L1xx_CONF_H - -/* Includes ------------------------------------------------------------------*/ -/* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */ -#include "stm32l1xx_adc.h" -#include "stm32l1xx_aes.h" -#include "stm32l1xx_comp.h" -#include "stm32l1xx_crc.h" -#include "stm32l1xx_dac.h" -#include "stm32l1xx_dbgmcu.h" -#include "stm32l1xx_dma.h" -#include "stm32l1xx_exti.h" -#include "stm32l1xx_flash.h" -#include "stm32l1xx_fsmc.h" -#include "stm32l1xx_gpio.h" -#include "stm32l1xx_i2c.h" -#include "stm32l1xx_iwdg.h" -#include "stm32l1xx_lcd.h" -#include "stm32l1xx_opamp.h" -#include "stm32l1xx_pwr.h" -#include "stm32l1xx_rcc.h" -#include "stm32l1xx_rtc.h" -#include "stm32l1xx_sdio.h" -#include "stm32l1xx_spi.h" -#include "stm32l1xx_syscfg.h" -#include "stm32l1xx_tim.h" -#include "stm32l1xx_usart.h" -#include "stm32l1xx_wwdg.h" -#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ - -/* Exported constants --------------------------------------------------------*/ -/* Uncomment the line below to expanse the "assert_param" macro in the - Standard Peripheral Library drivers code */ -/* #define USE_FULL_ASSERT 1 */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT - -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function which reports - * the name of the source file and the source line number of the call - * that failed. If expr is true, it returns no value. - * @retval None - */ - #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); -#else - #define assert_param(expr) ((void)0) -#endif /* USE_FULL_ASSERT */ - -#endif /* __STM32L1xx_CONF_H */ -