summaryrefslogtreecommitdiff
path: root/Libraries/NixieDriver/nixie_driver_config.c
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2023-03-03 00:02:25 +0300
committerOxore <oxore@protonmail.com>2023-03-03 00:24:54 +0300
commit2a260911f5abc4e03cb41474a49e01a571395155 (patch)
treea2342b619430d52c06cc90f37ad19b1eba3b7a10 /Libraries/NixieDriver/nixie_driver_config.c
parentd16620e6ba7467e9ef99bf61336ccd8fb4dfd813 (diff)
Remove precious comments, change encoding to utf-8
Diffstat (limited to 'Libraries/NixieDriver/nixie_driver_config.c')
-rw-r--r--Libraries/NixieDriver/nixie_driver_config.c140
1 files changed, 46 insertions, 94 deletions
diff --git a/Libraries/NixieDriver/nixie_driver_config.c b/Libraries/NixieDriver/nixie_driver_config.c
index 6b5ce8a..defc674 100644
--- a/Libraries/NixieDriver/nixie_driver_config.c
+++ b/Libraries/NixieDriver/nixie_driver_config.c
@@ -1,32 +1,26 @@
#include "nixie_driver_config.h"
-
static void NixieDriver_TIMConfig ( void );
static void NixieDriver_SPIConfig ( void );
-
-// ----------------------------------------------------------------------------
-//
-// ----------------------------------------------------------------------------
void NixieDriverConfig ( void )
{
NixieDriver_TIMConfig ();
NixieDriver_SPIConfig ();
}
-
// ----------------------------------------------------------------------------
-// Конфигурируем таймер на 100 мкс. В прерывании каждые 100 мкс будет
-// проворачиваться механизм динамической индикации ламп Nixie
+// Конфигурируем таймер на 100 мкс. В прерывании каждые 100 мкс будет
+// проворачиваться механизм динамической индикации ламп Nixie
// ----------------------------------------------------------------------------
static void NixieDriver_TIMConfig ( void )
{
NVIC_InitTypeDef NVIC_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
-
+
/* NIX_DRIVER_TIMx clock enable */
NIX_DRIVER_RCC_APBxPeriphClockCmd ( NIX_DRIVER_TIM_RCC, ENABLE );
-
+
/* Enable the NIX_DRIVER_TIMx gloabal Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = NIX_DRIVER_TIM_IRQx;
NVIC_InitStructure.NVIC_IRQChannelPriority = 1;
@@ -36,35 +30,35 @@ static void NixieDriver_TIMConfig ( void )
/* -----------------------------------------------------------------------
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 = 100; // Это миксросекунды //24999
+ TIM_TimeBaseStructure.TIM_Period = 100; // Это миксросекунды //24999
TIM_TimeBaseStructure.TIM_Prescaler = (SystemCoreClock/1000000)-1; //479;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit ( NIX_DRIVER_TIMx, &TIM_TimeBaseStructure );
-
+
/* NIX_DRIVER_TIMx Interrupts enable */
TIM_ITConfig ( NIX_DRIVER_TIMx, TIM_IT_Update, ENABLE );
-
+
/* NIX_DRIVER_TIMx enable counter */
TIM_Cmd ( NIX_DRIVER_TIMx, ENABLE );
}
@@ -78,22 +72,22 @@ static void NixieDriver_SPIConfig ( void )
GPIO_InitTypeDef GPIO_InitStructure;
SPI_InitTypeDef SPI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
-
+
/* Enable the SPI periph */
NIX_SPIx_RCC_APBxPeriphClockCmd ( NIX_SPIx_CLK, ENABLE );
-
+
/* Enable SCK, MOSI, MISO and NSS GPIO clocks */
- RCC_AHBPeriphClockCmd ( NIX_SPIx_SCK_GPIO_CLK |
- NIX_SPIx_MOSI_GPIO_CLK |
+ RCC_AHBPeriphClockCmd ( NIX_SPIx_SCK_GPIO_CLK |
+ NIX_SPIx_MOSI_GPIO_CLK |
NIX_SPIx_ST_GPIO_CLK |
NIX_GPIOx_TUB_P1_GPIO_CLK |
NIX_GPIOx_TUB_P2_GPIO_CLK,
ENABLE );
-
+
GPIO_PinAFConfig ( NIX_SPIx_SCK_GPIO_PORT, NIX_SPIx_SCK_SOURCE, NIX_SPIx_SCK_AF );
GPIO_PinAFConfig ( NIX_SPIx_MOSI_GPIO_PORT, NIX_SPIx_MOSI_SOURCE, NIX_SPIx_MOSI_AF );
//GPIO_PinAFConfig ( NIX_SPIx_ST_GPIO_PORT, NIX_SPIx_ST_SOURCE, NIX_SPIx_ST_AF );
-
+
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
@@ -106,7 +100,7 @@ static void NixieDriver_SPIConfig ( void )
/* SPI MOSI pin configuration */
GPIO_InitStructure.GPIO_Pin = NIX_SPIx_MOSI_PIN;
GPIO_Init ( NIX_SPIx_MOSI_GPIO_PORT, &GPIO_InitStructure );
-
+
/* GPIO ST pin configuration */
GPIO_InitStructure.GPIO_Pin = NIX_SPIx_ST_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
@@ -116,29 +110,28 @@ static void NixieDriver_SPIConfig ( void )
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;
GPIO_Init ( NIX_SPIx_ST_GPIO_PORT, &GPIO_InitStructure );
- // Пины управления точками на лампах (не хватило ног сдвиговых редисок)
-
- /* GPIO tub_dp1 pin configuration */
- GPIO_InitStructure.GPIO_Pin = NIX_GPIOx_TUB_DP1_PIN;
- 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_Level_3;
- GPIO_Init ( NIX_GPIOx_TUB_DP1_PORT, &GPIO_InitStructure );
-
- /* GPIO tub_dp2 pin configuration */
- GPIO_InitStructure.GPIO_Pin = NIX_GPIOx_TUB_DP2_PIN;
- 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_Level_3;
- GPIO_Init ( NIX_GPIOx_TUB_DP2_PORT, &GPIO_InitStructure );
-
-
+ // Пины управления точками на лампах (не хватило ног сдвиговых редисок)
+
+ /* GPIO tub_dp1 pin configuration */
+ GPIO_InitStructure.GPIO_Pin = NIX_GPIOx_TUB_DP1_PIN;
+ 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_Level_3;
+ GPIO_Init ( NIX_GPIOx_TUB_DP1_PORT, &GPIO_InitStructure );
+
+ /* GPIO tub_dp2 pin configuration */
+ GPIO_InitStructure.GPIO_Pin = NIX_GPIOx_TUB_DP2_PIN;
+ 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_Level_3;
+ GPIO_Init ( NIX_GPIOx_TUB_DP2_PORT, &GPIO_InitStructure );
+
/* SPI configuration -------------------------------------------------------*/
SPI_I2S_DeInit ( NIX_SPIx );
- SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
- //SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;
+ SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
+ //SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
@@ -149,61 +142,20 @@ static void NixieDriver_SPIConfig ( void )
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_Init ( NIX_SPIx, &SPI_InitStructure );
-
+
/* Enable the SPI peripheral */
SPI_Cmd ( NIX_SPIx, ENABLE );
-
+
/* Configure the SPI interrupt priority */
NVIC_InitStructure.NVIC_IRQChannel = NIX_SPIx_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init ( &NVIC_InitStructure );
-
+
// /* Enable the Tx buffer empty interrupt */
SPI_I2S_ITConfig ( NIX_SPIx, SPI_I2S_IT_TXE, ENABLE );
-
+
NIX_DRIVER_RESET_ST_PIN;
NIX_DRIVER_RESET_TUB_DP1_PIN;
NIX_DRIVER_RESET_TUB_DP2_PIN;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-