瀏覽代碼

All fine.

Vladimir N. Shilov 2 年之前
父節點
當前提交
89b7b8fe7e
共有 5 個文件被更改,包括 34 次插入8 次删除
  1. 5 0
      ReadMe.txt
  2. 2 1
      inc/display.h
  3. 7 4
      src/board.c
  4. 15 3
      src/display.c
  5. 5 0
      src/main.c

+ 5 - 0
ReadMe.txt

@@ -78,3 +78,8 @@ Display Ctrl	HT1632C (устаревшая, не лучший выбор)
 
 Запаял другую DS3231 - и всё заработало...
 Можно двигаться дальше.
+---
+2022.09.22
+
+Вывод бегущей строки на отдельном таймере. Красота...
+Ещё можно как-кто вынести бибикалку, что-бы не зависеть от шедулера.

+ 2 - 1
inc/display.h

@@ -7,7 +7,7 @@
 
 /* Exported constants */
 #define DISPLAY_COLUMNS       24
-#define DISPLAY_REFRESH_MS    50
+#define DISPLAY_REFRESH_MS    30
 
 /* Variables */
 extern uint8_t display_Buffer[];
@@ -23,6 +23,7 @@ void display_LedState(dis_en_t state);
 void display_Fill(uint8_t pattern);
 void display_Char(const uint8_t symb, uint8_t column);
 void display_String(const char * string, uint8_t repeat);
+void display_Wait4Display(void);
 void TIM16_IRQHandler(void);
 
 #endif /* _DISPLAY_H_ */

+ 7 - 4
src/board.c

@@ -25,7 +25,7 @@ void Board_Init(void)
   /* Main peripheral clock enable */
   RCC->AHBENR |= (RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN | RCC_AHBENR_DMAEN);
   RCC->APB1ENR = (RCC_APB1ENR_PWREN | RCC_APB1ENR_I2C1EN); // | RCC_APB1ENR_TIM14EN| RCC_APB1ENR_TIM3EN);
-  RCC->APB2ENR = (RCC_APB2ENR_SYSCFGEN | RCC_APB2ENR_SPI1EN | RCC_APB2ENR_TIM1EN | RCC_APB2ENR_TIM17EN); // | RCC_APB2ENR_TIM16EN
+  RCC->APB2ENR = (RCC_APB2ENR_SYSCFGEN | RCC_APB2ENR_SPI1EN | RCC_APB2ENR_TIM1EN | RCC_APB2ENR_TIM16EN | RCC_APB2ENR_TIM17EN);
 
   /* Peripheral interrupt init*/
   /* RCC_IRQn interrupt configuration */
@@ -172,8 +172,8 @@ static void SPI1_Init(void)
   DMA1_Channel3->CCR = (DMA_CCR_PL_1 | DMA_CCR_MINC | DMA_CCR_DIR | DMA_CCR_CIRC | DMA_CCR_TCIE); // | DMA_CCR_TEIE
 
   /* SPI1 interrupt Init */
-  NVIC_SetPriority(SPI1_IRQn, 0);
-  NVIC_EnableIRQ(SPI1_IRQn);
+  //NVIC_SetPriority(SPI1_IRQn, 0);
+  //NVIC_EnableIRQ(SPI1_IRQn);
 
   /* SPI1 parameter configuration: master mode, data 8 bit, divider = 2, TX DMA SPI_CR1_BR_2 | SPI_CR1_BR_0 |  */
   SPI1->CR1 = (SPI_CR1_MSTR | SPI_CR1_SSM | SPI_CR1_SSI | SPI_CR1_CPOL | SPI_CR1_CPHA | SPI_CR1_LSBFIRST);
@@ -210,7 +210,10 @@ static void TIM1_Init(void)
   */
 static void TIM16_Init(void)
 {
-  /* setup clock */
+  /* SPI1 interrupt Init */
+  NVIC_SetPriority(TIM16_IRQn, 0);
+  NVIC_EnableIRQ(TIM16_IRQn);
+
   TIM16->PSC = (48000-1); // prescaler for 1 mS
   TIM16->ARR = DISPLAY_REFRESH_MS; // auto reload value, mS
   TIM16->CR1 = TIM_CR1_ARPE;

+ 15 - 3
src/display.c

@@ -85,9 +85,8 @@ void display_String(const char * string, uint8_t repeat) {
   if (repeat == 0) { return; }
   if (string[0] == 0) { return; }
 
-  /* wait if display is busy */
-  while (Flag.DISP_BSY != 0) { __NOP(); }
-  
+  display_Wait4Display();
+ 
   String.Repeat = repeat; // charge global counter
   String.j = DISPLAY_COLUMNS;
 
@@ -103,7 +102,9 @@ void display_String(const char * string, uint8_t repeat) {
   String.k = 0;
   String.j ++;
   Flag.DISP_BSY = 1;
+  TIM16->EGR = TIM_EGR_UG; // force timer update
   TIM16->CR1 |= TIM_CR1_CEN; // start tim16 counter
+  TIM16_IRQHandler();
 }
 
 /**
@@ -359,6 +360,17 @@ void display_Fill(uint8_t pattern) {
   display_WriteBuffer();
 }
 
+/**
+ * @brief Wait while displaye is busy for running string
+ */
+void display_Wait4Display(void) {
+  /* wait if display is busy */
+  while (Flag.DISP_BSY != 0) { 
+    RTOS_DispatchTask();
+    __WFI();
+   }
+}
+
 /**
   * @brief This function handles TIM16 global interrupt.
   */

+ 5 - 0
src/main.c

@@ -40,6 +40,7 @@ int main(void)
   RTOS_Init();
 
   display_Init();
+  bip_Bip();
   display_String("Electronica Alpha-12\0", 1);
 
   /* Real-Time clock */
@@ -126,6 +127,8 @@ void bip_Bip(void) {
  * @brief Show MM:SS use 4x7 digits
  */
 static void Show_MMSS(void) {
+  display_Wait4Display();
+
   uint8_t t;
   // dots on
   display_WriteData(&digit_4x7[10][0], 10, 4);
@@ -147,6 +150,8 @@ static void Show_MMSS(void) {
 }
 
 static void dots_Off(void) {
+  display_Wait4Display();
+
   display_Buffer[11] = 0x0;
   display_Buffer[12] = 0x0;
   display_WriteBuffer();