diff --git a/bsl/csl/interfaces/pin.h b/bsl/csl/interfaces/pin.h index f69b0fe..f5b14bc 100644 --- a/bsl/csl/interfaces/pin.h +++ b/bsl/csl/interfaces/pin.h @@ -78,7 +78,7 @@ typedef enum output, /*!< Set pin as **Output** */ analog, /*!< Set pin as **Analog** */ alternate /*!< Set pin as **Alternate** */ -}mode_t; +}pinMode_t; /*! Enum of possible Outpout Stages */ typedef enum @@ -87,7 +87,7 @@ typedef enum floating, /*!< Set ouput stage to **Floating** */ pushPull, /*!< Set ouput stage to **Push Pull** */ openDrain /*!< Set ouput stage to **Open Drain** */ -}stage_t; +}pinStage_t; /*! Enum for the internal Pull-Up/Down resistors */ typedef enum @@ -96,7 +96,7 @@ typedef enum none, /*!< **Disbales** internal resistance */ pullUp, /*!< Set internal resistance as **Pull-Up** */ pullDown /*!< Set internal resistance as **Pull-Down** */ -}pullUpDown_t; +}pinPullUpDown_t; /*! Enum to set the pin's speed*/ typedef enum @@ -106,22 +106,22 @@ typedef enum normal, /*!< set pin's speed to **Normal** */ fast, /*!< set pin's speed to **Fast** */ veryFast /*!< set pin's speed to **Very Fast** */ -}speed_t; +}pinSpeed_t; typedef enum { disabled, enabled -}interrupt_t; +}pinInterrupt_t; typedef struct { - mode_t md; - stage_t st; - pullUpDown_t pud; - speed_t sp; - interrupt_t intr; -}configuration_t; + pinMode_t md; + pinStage_t st; + pinPullUpDown_t pud; + pinSpeed_t sp; + pinInterrupt_t intr; +}pinConfiguration_t; typedef enum @@ -138,34 +138,34 @@ typedef enum Bocked, AlreadyUsed, NotGpio -}errors_t; +}pinErrors_t; /** * @brief Configuration function that will call all the necessary function for an sucessfull pin initialisation * @param pinNo_t mode_t * @retval none */ -void pinConfig(pinNo_t pinNo, mode_t mode, stage_t stage, pullUpDown_t resistance, speed_t speed); +void pinConfig(pinNo_t pinNo, pinMode_t mode, pinStage_t stage, pinPullUpDown_t resistance, pinSpeed_t speed); /** * @brief Modes to set the direction or function of the pin */ -void pinSetMode(pinNo_t pinNo, mode_t mode); +void pinSetMode(pinNo_t pinNo, pinMode_t mode); /** * @brief Output Stage Push-Pull High-z ect... */ -void pinSetOutputStage(pinNo_t pinNo, stage_t stage); +void pinSetOutputStage(pinNo_t pinNo, pinStage_t stage); /** * @brief Depending of the hardare it is able to select the speed of given pins */ -void pinSetSpeed(pinNo_t pinNo, speed_t speed); +void pinSetSpeed(pinNo_t pinNo, pinSpeed_t speed); /** * @brief If internal Pull-up or Pull-donws are wailable */ -void pinSetPullUpDonw(pinNo_t pinNo, pullUpDown_t resistance); +void pinSetPullUpDonw(pinNo_t pinNo, pinPullUpDown_t resistance); /** * @brief If pin is set as alternate this function will modify the pins functionality diff --git a/bsl/csl/interfaces/usart.h b/bsl/csl/interfaces/usart.h index c1a976e..7b3dfce 100644 --- a/bsl/csl/interfaces/usart.h +++ b/bsl/csl/interfaces/usart.h @@ -74,6 +74,8 @@ void usartSetBaudRate(uint32_t baud); */ void usartSendChar(int ch); +void print_Usart(char *ptr); + #ifdef __cplusplus } #endif diff --git a/bsl/csl/stm32f042/Drivers/CMakeLists.txt b/bsl/csl/stm32f042/Drivers/CMakeLists.txt index 197cf18..f2c8795 100644 --- a/bsl/csl/stm32f042/Drivers/CMakeLists.txt +++ b/bsl/csl/stm32f042/Drivers/CMakeLists.txt @@ -1,6 +1,6 @@ set(STM_DRIVER_SOURCES - STM32F0xx_HAL_Driver/Src/stm32f0xx_ll_exti.c - STM32F0xx_HAL_Driver/Src/stm32f0xx_ll_gpio.c + # STM32F0xx_HAL_Driver/Src/stm32f0xx_ll_exti.c + # STM32F0xx_HAL_Driver/Src/stm32f0xx_ll_gpio.c STM32F0xx_HAL_Driver/Src/stm32f0xx_ll_pwr.c STM32F0xx_HAL_Driver/Src/stm32f0xx_ll_rcc.c STM32F0xx_HAL_Driver/Src/stm32f0xx_ll_utils.c diff --git a/bsl/csl/stm32f042/Src/CMakeLists.txt b/bsl/csl/stm32f042/Src/CMakeLists.txt index 3c3f420..b5fb86b 100644 --- a/bsl/csl/stm32f042/Src/CMakeLists.txt +++ b/bsl/csl/stm32f042/Src/CMakeLists.txt @@ -4,7 +4,6 @@ set (STMSRC_INCLUDES set(STMSRC_SOURCES stm32f0xx_csl.c - #stm32f0xx_it.c system_stm32f0xx.c ) diff --git a/bsl/csl/stm32f042/Src/pin.c b/bsl/csl/stm32f042/Src/pin.c index 295faa7..b209637 100644 --- a/bsl/csl/stm32f042/Src/pin.c +++ b/bsl/csl/stm32f042/Src/pin.c @@ -92,7 +92,7 @@ const uint32_t outputStgeList[4] = OTYPER_OPEN_DRAIN }; -void pinSetMode(pinNo_t pinNo, mode_t mode) +void pinSetMode(pinNo_t pinNo, pinMode_t mode) { //Clear entry. PIN_BASE->MODER &=~ (0x3 << (PIN_NO * 2)); @@ -100,19 +100,19 @@ void pinSetMode(pinNo_t pinNo, mode_t mode) PIN_BASE->MODER |= (moderMode[mode] << (PIN_NO * 2)); } -void pinSetOutputStage(pinNo_t pinNo, stage_t stage) +void pinSetOutputStage(pinNo_t pinNo, pinStage_t stage) { PIN_BASE->OTYPER &= ~(1 << PIN_NO); PIN_BASE->OTYPER |= (outputStgeList[stage] << PIN_NO); } -void pinSetPullUpDonw(pinNo_t pinNo, pullUpDown_t resistance) +void pinSetPullUpDonw(pinNo_t pinNo, pinPullUpDown_t resistance) { PIN_BASE->PUPDR &= ~(0x3 << (PIN_NO * 2)); PIN_BASE->PUPDR |= (pinPullUpDown[resistance] << (PIN_NO * 2)); } -void pinSetSpeed(pinNo_t pinNo, speed_t speed) +void pinSetSpeed(pinNo_t pinNo, pinSpeed_t speed) { PIN_BASE->OSPEEDR &= (0x3 << (PIN_NO * 2)); PIN_BASE->OSPEEDR |= (speedList[speed] << (PIN_NO * 2)); @@ -130,7 +130,7 @@ void pinSetAlternate(pinNo_t pinNo, uint16_t alternate) PIN_BASE->AFR[1] |= ((alternate & 0x0F) << (PIN_NO * 4)); } -void pinConfig(pinNo_t pinNo, mode_t mode, stage_t stage, pullUpDown_t resistance, speed_t speed) +void pinConfig(pinNo_t pinNo, pinMode_t mode, pinStage_t stage, pinPullUpDown_t resistance, pinSpeed_t speed) { pinInit(pinNo); //Very important to init first so that the corresponding bus gets his clock pinSetMode(pinNo, mode); diff --git a/bsl/csl/stm32f042/Src/usart.c b/bsl/csl/stm32f042/Src/usart.c index 2393455..20804d6 100644 --- a/bsl/csl/stm32f042/Src/usart.c +++ b/bsl/csl/stm32f042/Src/usart.c @@ -31,7 +31,17 @@ #define SYST_CLK 8000000 #define AF1 0x01 -void usartSetBaudRate(uint32_t baud); + +void print_Usart(char *ptr) +{ + uint16_t len = 0; + + while(ptr[len] != '\0') + { + usartSendChar(ptr[len]); + len++; + } +} void usartInit() { diff --git a/main.cpp b/main.cpp index 65d575f..44df8e3 100644 --- a/main.cpp +++ b/main.cpp @@ -1,27 +1,28 @@ -#include"main.hpp" -#include"bsl/csl/interfaces/delay.h" -#include"stm32f0xx_csl.h" +#include "main.hpp" +#include "delay.h" +#include "stm32f0xx_csl.h" #include "usart.h" int main(int argc, char *argv[]) { - uint8_t i = 0; stmStart(); pinConfig(pinB3, output, pushPull, none, normal); pinConfig(pinA0, input, pushPull, pullDown, normal); + usartInit(); + print_Usart("Wellcome to our KED project\n\r"); + for(i = 0 ; i < 10 ; i++) { delayMs(100); pinToggle(pinB3); - usartSendChar('y'); delayMs(100); } - + pinWrite(pinB3,0); while(1)