diff options
Diffstat (limited to 'Libraries/LED_Driver')
-rw-r--r-- | Libraries/LED_Driver/led_driver_config.c | 61 | ||||
-rw-r--r-- | Libraries/LED_Driver/led_driver_config.h | 16 | ||||
-rw-r--r-- | Libraries/LED_Driver/led_driver_process.h | 2 | ||||
-rw-r--r-- | Libraries/LED_Driver/led_driver_task.c | 6 |
4 files changed, 39 insertions, 46 deletions
diff --git a/Libraries/LED_Driver/led_driver_config.c b/Libraries/LED_Driver/led_driver_config.c index d71792d..3b2b081 100644 --- a/Libraries/LED_Driver/led_driver_config.c +++ b/Libraries/LED_Driver/led_driver_config.c @@ -4,7 +4,7 @@ static void LED_TIMConfig ( void ); static void LED_SPIConfig ( void ); // ---------------------------------------------------------------------------- -// , RGB +// Подготовка железа, прерываний и тд для работы с RGB светодиодиками // ---------------------------------------------------------------------------- void LED_Driver_Config ( void ) { @@ -20,49 +20,48 @@ static void LED_TIMConfig ( void ) { NVIC_InitTypeDef NVIC_InitStructure; TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; - + /* LED_TIMx clock enable */ LED_RCC_APBxPeriphClockCmd ( LED_TIM_RCC, ENABLE ); - + /* Enable the LED_TIMx gloabal Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = LED_TIM_IRQx; - NVIC_InitStructure.NVIC_IRQChannelPriority = 2; // , NixieDriver + NVIC_InitStructure.NVIC_IRQChannelPriority = 2; // Установим приоритет ниже, чем у модуля NixieDriver NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init ( &NVIC_InitStructure ); /* ----------------------------------------------------------------------- In this example TIM7 counter clock (TIM7CLK) is set to APB1 clock (PCLK1), since APB1 prescaler is set to 1 and TIM7 prescaler is set to 0. - - In this example TIM7 input clock (TIM7CLK) is set to APB1 clock (PCLK1), - since APB1 prescaler is set to 1. + + In this example TIM7 input clock (TIM7CLK) is set to APB1 clock (PCLK1), + since APB1 prescaler is set to 1. TIM7CLK = PCLK1 = HCLK = SystemCoreClock - + With Prescaler set to 479 and Period to 24999, the TIM7 counter is updated each 250 ms (i.e. and interrupt is generated each 250 ms) TIM7 counter clock = TIM7CLK /((Prescaler + 1)*(Period + 1)) = 48 MHz / ((25000)*(480)) - = 4 Hz + = 4 Hz ==> TIM7 counter period = 250 ms Note: SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f0xx.c file. Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate() function to update SystemCoreClock variable value. Otherwise, any configuration - based on this variable will be incorrect. - ----------------------------------------------------------------------- */ - + based on this variable will be incorrect. + ----------------------------------------------------------------------- */ + /* Time base configuration */ - TIM_TimeBaseStructure.TIM_Period = 1000; // //24999 + TIM_TimeBaseStructure.TIM_Period = 1000; // Это миксросекунды //24999 TIM_TimeBaseStructure.TIM_Prescaler = (SystemCoreClock/1000000)-1; //479; TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; - //TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; TIM_TimeBaseInit ( LED_TIMx, &TIM_TimeBaseStructure ); - + /* LED_TIMx Interrupts enable */ TIM_ITConfig ( LED_TIMx, TIM_IT_Update, ENABLE ); - + /* LED_TIMx enable counter */ TIM_Cmd ( LED_TIMx, ENABLE ); } @@ -76,20 +75,19 @@ static void LED_SPIConfig ( void ) GPIO_InitTypeDef GPIO_InitStructure; SPI_InitTypeDef SPI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; - + /* Enable the SPI periph */ LED_SPIx_RCC_APBxPeriphClockCmd ( LED_SPIx_CLK, ENABLE ); - + /* Enable SCK, MOSI, MISO and NSS GPIO clocks */ - RCC_AHBPeriphClockCmd ( LED_SPIx_SCK_GPIO_CLK | - LED_SPIx_MOSI_GPIO_CLK | + RCC_AHBPeriphClockCmd ( LED_SPIx_SCK_GPIO_CLK | + LED_SPIx_MOSI_GPIO_CLK | LED_SPIx_ST_GPIO_CLK, ENABLE ); - + GPIO_PinAFConfig ( LED_SPIx_SCK_GPIO_PORT, LED_SPIx_SCK_SOURCE, LED_SPIx_SCK_AF ); GPIO_PinAFConfig ( LED_SPIx_MOSI_GPIO_PORT, LED_SPIx_MOSI_SOURCE, LED_SPIx_MOSI_AF ); - //GPIO_PinAFConfig ( LED_SPIx_ST_GPIO_PORT, LED_SPIx_ST_SOURCE, LED_SPIx_ST_AF ); - + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; @@ -102,21 +100,18 @@ static void LED_SPIConfig ( void ) /* SPI MOSI pin configuration */ GPIO_InitStructure.GPIO_Pin = LED_SPIx_MOSI_PIN; GPIO_Init ( LED_SPIx_MOSI_GPIO_PORT, &GPIO_InitStructure ); - + /* GPIO ST pin configuration */ GPIO_InitStructure.GPIO_Pin = LED_SPIx_ST_PIN; - //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - //GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3; GPIO_Init ( LED_SPIx_ST_GPIO_PORT, &GPIO_InitStructure ); - + /* SPI configuration -------------------------------------------------------*/ SPI_I2S_DeInit ( LED_SPIx ); - //SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx; //SPI_Direction_2Lines_FullDuplex - SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; + SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b; SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; @@ -126,18 +121,18 @@ static void LED_SPIConfig ( void ) SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_InitStructure.SPI_Mode = SPI_Mode_Master; SPI_Init ( LED_SPIx, &SPI_InitStructure ); - + /* Enable the SPI peripheral */ SPI_Cmd ( LED_SPIx, ENABLE ); - + /* Configure the SPI interrupt priority */ NVIC_InitStructure.NVIC_IRQChannel = LED_SPIx_IRQn; NVIC_InitStructure.NVIC_IRQChannelPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init ( &NVIC_InitStructure ); - + /* Enable the Rx buffer not empty interrupt */ SPI_I2S_ITConfig ( LED_SPIx, SPI_I2S_IT_RXNE, ENABLE ); - + LED_ST_PIN_RESET; } diff --git a/Libraries/LED_Driver/led_driver_config.h b/Libraries/LED_Driver/led_driver_config.h index 7e377ac..39927ec 100644 --- a/Libraries/LED_Driver/led_driver_config.h +++ b/Libraries/LED_Driver/led_driver_config.h @@ -9,27 +9,27 @@ #define LED_SPIx_IRQn SPI2_IRQn #define LED_SPIx_IRQHandler SPI2_IRQHandler -#define LED_SPIx_SCK_PIN GPIO_Pin_10 -#define LED_SPIx_SCK_GPIO_PORT GPIOB +#define LED_SPIx_SCK_PIN GPIO_Pin_10 +#define LED_SPIx_SCK_GPIO_PORT GPIOB #define LED_SPIx_SCK_GPIO_CLK RCC_AHBPeriph_GPIOB #define LED_SPIx_SCK_SOURCE GPIO_PinSource10 #define LED_SPIx_SCK_AF GPIO_AF_5 -#define LED_SPIx_MOSI_PIN GPIO_Pin_15 -#define LED_SPIx_MOSI_GPIO_PORT GPIOB +#define LED_SPIx_MOSI_PIN GPIO_Pin_15 +#define LED_SPIx_MOSI_GPIO_PORT GPIOB #define LED_SPIx_MOSI_GPIO_CLK RCC_AHBPeriph_GPIOB #define LED_SPIx_MOSI_SOURCE GPIO_PinSource15 #define LED_SPIx_MOSI_AF GPIO_AF_0 -#define LED_SPIx_ST_PIN GPIO_Pin_9 -#define LED_SPIx_ST_GPIO_PORT GPIOB +#define LED_SPIx_ST_PIN GPIO_Pin_9 +#define LED_SPIx_ST_GPIO_PORT GPIOB #define LED_SPIx_ST_GPIO_CLK RCC_AHBPeriph_GPIOA #define LED_SPIx_ST_SOURCE GPIO_PinSource9 #define LED_SPIx_ST_AF GPIO_AF_5 #define LED_SPIx_RCC_APBxPeriphClockCmd RCC_APB1PeriphClockCmd -// LedRgbDriver ------------------------------------- // +// Определения для таймера LedRgbDriver ------------------------------------- // #define LED_TIMx TIM3 #define LED_TIM_IRQHandler TIM3_IRQHandler #define LED_TIM_RCC RCC_APB1Periph_TIM3 @@ -41,4 +41,4 @@ void LED_Driver_Config ( void ); -#endif //LED_DRIVER_CONFIG_INCLUDED
\ No newline at end of file +#endif //LED_DRIVER_CONFIG_INCLUDED diff --git a/Libraries/LED_Driver/led_driver_process.h b/Libraries/LED_Driver/led_driver_process.h index 346a0c4..fa02241 100644 --- a/Libraries/LED_Driver/led_driver_process.h +++ b/Libraries/LED_Driver/led_driver_process.h @@ -3,4 +3,4 @@ void LEDDriverProcessFromISR ( void ); -#endif //LED_DRIVER_PROCESS_INCLUDED
\ No newline at end of file +#endif //LED_DRIVER_PROCESS_INCLUDED diff --git a/Libraries/LED_Driver/led_driver_task.c b/Libraries/LED_Driver/led_driver_task.c index 33b677a..d38deb4 100644 --- a/Libraries/LED_Driver/led_driver_task.c +++ b/Libraries/LED_Driver/led_driver_task.c @@ -1,7 +1,6 @@ #include "led_driver_task.h" #include "led_driver_config.h" -// FreeRTOS includes #include "FreeRTOS.h" #include "task.h" #include "queue.h" @@ -19,10 +18,9 @@ void ProcessFSM_LED_RGB ( void ) } // ---------------------------------------------------------------------------- -// , RGB +// Задача ОС, реализующая задачу обработки светодиодиков RGB // ---------------------------------------------------------------------------- void LED_Driver_Task ( void *pvParameters ) { while(1)ProcessFSM_LED_RGB (); - //vTaskDelete(NULL); -}
\ No newline at end of file +} |