Skip to content
Snippets Groups Projects
Commit c51c371b authored by Flax's avatar Flax
Browse files

STM32L011K4 : corrected SPI1 pinout, added SPI enable in display module.

parent ba0b7d4a
No related branches found
No related tags found
No related merge requests found
......@@ -101,8 +101,6 @@ void Error_Handler(void);
#define TCK_GPIO_Port GPIOA
#define VCP_RX_Pin LL_GPIO_PIN_15
#define VCP_RX_GPIO_Port GPIOA
#define LED_BLUE_Pin LL_GPIO_PIN_3
#define LED_BLUE_GPIO_Port GPIOB
#define DISPLAY_LATCH_Pin LL_GPIO_PIN_4
#define DISPLAY_LATCH_GPIO_Port GPIOB
#define DISPLAY_K1_Pin LL_GPIO_PIN_6
......
......@@ -84,7 +84,12 @@
#define mREGOutputsDisplayK3SetState() (LL_GPIO_SetOutputPin(mREG_DISPLAY_K3_GPIO_Port, mREG_DISPLAY_K3_Pin))
#define mREGOutputsDisplayK3ResetState() (LL_GPIO_ResetOutputPin(mREG_DISPLAY_K3_GPIO_Port, mREG_DISPLAY_K3_Pin))
#define mREGOutputsDisplayLATCHSetState() (LL_GPIO_SetOutputPin(mREG_DISPLAY_LATCH_GPIO_Port, mREG_DISPLAY_LATCH_Pin))
#define mREGOutputsDisplayLATCHResetState() (LL_GPIO_ResetOutputPin(mREG_DISPLAY_LATCH_GPIO_Port, mREG_DISPLAY_LATCH_Pin))
/* SPI --------------------------------------------------------*/
#define mREGSpi1Enable() (LL_SPI_Enable(SPI1))
#define mREGSpi1Disable() (LL_SPI_Disable(SPI1))
#define mREGSpi1InterruptRxEnable() (LL_SPI_EnableIT_RXNE(SPI1))
#define mREGSpi1InterruptRxDisable() (LL_SPI_DisableIT_RXNE(SPI1))
#define mREGSpi1SendFrame(frame) (LL_SPI_TransmitData8(SPI1, frame))
......
......@@ -48,7 +48,7 @@ const static uint8_t cDISPSevenSegmentTable_U8A[] =
// Local variables
// ===============
static uint8_t DISPSevenSegBuffer_U8A [cDISPMaxDigit];
static uint8_t DISPSevenSegelect_U8;
static uint8_t DISPSevenSegSelect_U8;
static bool DISPEnableDisplay_B;
// ===========================
......@@ -107,18 +107,20 @@ bool DISPValueToDigits (uint16_t value_u16, uint8_t* digits_U8A[])
// ============================
void DISPInit (void)
{
DISPSevenSegelect_U8 = 0U;
DISPSevenSegSelect_U8 = 0U;
DISPEnableDisplay_B = false;
}
void DISPStart (void)
{
mREGSpi1InterruptRxEnable();
mREGSpi1Enable();
DISPEnableDisplay();
}
void DISPStop (void)
{
mREGSpi1Disable();
mREGSpi1InterruptRxDisable();
}
......@@ -144,23 +146,24 @@ char DISPNumberToChar (uint8_t number_u8)
void DISPRefresh (void)
{
// Switch active digit
if (DISPSevenSegelect_U8 < cDISPMaxDigit)
if (DISPSevenSegSelect_U8 < cDISPMaxDigit)
{
DISPSevenSegelect_U8++;
DISPSevenSegSelect_U8++;
}
else
{
DISPSevenSegelect_U8 = 0U;
DISPSevenSegSelect_U8 = 0U;
}
// Disable display before changing value
mREGOutputsDisplayK1ResetState();
mREGOutputsDisplayK2ResetState();
mREGOutputsDisplayK3ResetState();
mREGOutputsDisplayLATCHResetState();
// Refresh
mREGSpi1InterruptRxEnable();
mREGSpi1SendFrame(&DISPSevenSegBuffer_U8A[DISPSevenSegelect_U8]);
mREGSpi1SendFrame(DISPSevenSegBuffer_U8A[DISPSevenSegSelect_U8]);
}
void DISPEnableDisplay (void)
......@@ -183,7 +186,7 @@ void DISPInterruptRx (void)
uint8_t rx_u8;
if (DISPEnableDisplay_B == true)
{ // Enable active digit
switch (DISPSevenSegelect_U8)
switch (DISPSevenSegSelect_U8)
{
case 0U: // Enable K1
mREGOutputsDisplayK1SetState();
......@@ -206,6 +209,8 @@ void DISPInterruptRx (void)
mREGOutputsDisplayK3ResetState();
break;
}
mREGOutputsDisplayLATCHSetState(); // Latch value
}
else
{ // Disable display
......
......@@ -339,19 +339,18 @@ static void MX_SPI1_Init(void)
/* Peripheral clock enable */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SPI1);
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA);
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB);
/**SPI1 GPIO Configuration
PA5 ------> SPI1_SCK
PB3 ------> SPI1_SCK
PB5 ------> SPI1_MOSI
*/
GPIO_InitStruct.Pin = LL_GPIO_PIN_5;
GPIO_InitStruct.Pin = LL_GPIO_PIN_3;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LL_GPIO_PIN_5;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
......@@ -576,9 +575,6 @@ static void MX_GPIO_Init(void)
/**/
LL_GPIO_ResetOutputPin(DISPLAY_K3_GPIO_Port, DISPLAY_K3_Pin);
/**/
LL_GPIO_ResetOutputPin(LED_BLUE_GPIO_Port, LED_BLUE_Pin);
/**/
LL_GPIO_ResetOutputPin(DISPLAY_LATCH_GPIO_Port, DISPLAY_LATCH_Pin);
......@@ -668,14 +664,6 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
LL_GPIO_Init(DISPLAY_K3_GPIO_Port, &GPIO_InitStruct);
/**/
GPIO_InitStruct.Pin = LED_BLUE_Pin;
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
LL_GPIO_Init(LED_BLUE_GPIO_Port, &GPIO_InitStruct);
/**/
GPIO_InitStruct.Pin = DISPLAY_LATCH_Pin;
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
......
......@@ -27,30 +27,29 @@ Mcu.Name=STM32L011K(3-4)Tx
Mcu.Package=LQFP32
Mcu.Pin0=PC14-OSC32_IN
Mcu.Pin1=PC15-OSC32_OUT
Mcu.Pin10=PA9
Mcu.Pin11=PA10
Mcu.Pin12=PA11
Mcu.Pin13=PA12
Mcu.Pin14=PA13
Mcu.Pin15=PA14
Mcu.Pin16=PA15
Mcu.Pin17=PB3
Mcu.Pin18=PB4
Mcu.Pin19=PB5
Mcu.Pin10=PA10
Mcu.Pin11=PA11
Mcu.Pin12=PA12
Mcu.Pin13=PA13
Mcu.Pin14=PA14
Mcu.Pin15=PA15
Mcu.Pin16=PB3
Mcu.Pin17=PB4
Mcu.Pin18=PB5
Mcu.Pin19=PB6
Mcu.Pin2=PA0-CK_IN
Mcu.Pin20=PB6
Mcu.Pin21=PB7
Mcu.Pin22=VP_TIM2_VS_ClockSourceINT
Mcu.Pin23=VP_TIM21_VS_ClockSourceINT
Mcu.Pin24=VP_TIM21_VS_no_output1
Mcu.Pin20=PB7
Mcu.Pin21=VP_TIM2_VS_ClockSourceINT
Mcu.Pin22=VP_TIM21_VS_ClockSourceINT
Mcu.Pin23=VP_TIM21_VS_no_output1
Mcu.Pin3=PA2
Mcu.Pin4=PA3
Mcu.Pin5=PA4
Mcu.Pin6=PA5
Mcu.Pin7=PB0
Mcu.Pin8=PB1
Mcu.Pin9=PA8
Mcu.PinsNb=25
Mcu.Pin6=PB0
Mcu.Pin7=PB1
Mcu.Pin8=PA8
Mcu.Pin9=PA9
Mcu.PinsNb=24
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32L011K4Tx
......@@ -108,9 +107,6 @@ PA3.Locked=true
PA3.Signal=GPXTI3
PA4.Mode=I2C
PA4.Signal=I2C1_SCL
PA5.Locked=true
PA5.Mode=TX_Only_Simplex_Unidirect_Master
PA5.Signal=SPI1_SCK
PA8.GPIOParameters=GPIO_Label
PA8.GPIO_Label=PWM_HEATER
PA8.Signal=S_TIM2_CH1
......@@ -128,10 +124,9 @@ PB1.GPIOParameters=GPIO_Label
PB1.GPIO_Label=LED
PB1.Locked=true
PB1.Signal=GPIO_Output
PB3.GPIOParameters=GPIO_Label
PB3.GPIO_Label=LED_BLUE
PB3.Locked=true
PB3.Signal=GPIO_Output
PB3.Mode=TX_Only_Simplex_Unidirect_Master
PB3.Signal=SPI1_SCK
PB4.GPIOParameters=GPIO_Label
PB4.GPIO_Label=DISPLAY_LATCH
PB4.Locked=true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment