|
@@ -2,6 +2,7 @@
|
|
|
#include "font.h"
|
|
|
#include "digits.h"
|
|
|
|
|
|
+/* Private typedefs */
|
|
|
/* Private defines */
|
|
|
#define FRAMEBUFFER_ROTATE
|
|
|
|
|
@@ -15,6 +16,14 @@
|
|
|
/* private macros */
|
|
|
/* Private variables */
|
|
|
uint8_t display_Buffer[DISPLAY_COLUMNS] = {0};
|
|
|
+static struct Running_Sring {
|
|
|
+ uint8_t Buf[STR_BUF_SIZE];
|
|
|
+ int Repeat;
|
|
|
+ int k;
|
|
|
+ int j;
|
|
|
+} String = {0};
|
|
|
+
|
|
|
+uint32_t str_Repeat = 0;
|
|
|
|
|
|
/* Privae fuctions */
|
|
|
static void _display_WriteBits(uint16_t data, uint16_t nbits);
|
|
@@ -26,6 +35,10 @@ static void _delay_c(uint32_t cycle);
|
|
|
* @brief Initialization HT1632C
|
|
|
*/
|
|
|
void display_Init(void) {
|
|
|
+ /* stop display if running */
|
|
|
+ TIM16->CR1 &= ~(TIM_CR1_CEN);
|
|
|
+ Flag.DISP_BSY = 0;
|
|
|
+
|
|
|
/* Wait for SPI */
|
|
|
while ((SPI1->SR & SPI_SR_BSY) != 0) { __NOP(); }
|
|
|
|
|
@@ -72,26 +85,25 @@ void display_String(const char * string, uint8_t repeat) {
|
|
|
if (repeat == 0) { return; }
|
|
|
if (string[0] == 0) { return; }
|
|
|
|
|
|
- uint8_t str_buf[STR_BUF_SIZE] = {0};
|
|
|
- int i = 0, j = DISPLAY_COLUMNS, k=0;
|
|
|
+ /* wait if display is busy */
|
|
|
+ while (Flag.DISP_BSY != 0) { __NOP(); }
|
|
|
+
|
|
|
+ String.Repeat = repeat; // charge global counter
|
|
|
+ String.j = DISPLAY_COLUMNS;
|
|
|
+
|
|
|
+ int i = 0, k=0;
|
|
|
while ((string[i] != '\0') && (i < STR_BUF_SYM)) {
|
|
|
for(k=0; k<FONT_WIDTH; k++) {
|
|
|
- str_buf[j] = Font_6x8[(uint8_t)string[i]][k];
|
|
|
- j ++;
|
|
|
+ String.Buf[String.j] = Font_6x8[(uint8_t)string[i]][k];
|
|
|
+ String.j ++;
|
|
|
}
|
|
|
i ++;
|
|
|
}
|
|
|
-
|
|
|
- while (repeat) {
|
|
|
- for (k=0; k<=j; k++) {
|
|
|
- display_WriteBuf(&str_buf[k]);
|
|
|
- tdelay_ms(50);
|
|
|
- }
|
|
|
- tdelay_ms(200);
|
|
|
|
|
|
- /* End of man loop */
|
|
|
- repeat --;
|
|
|
- }
|
|
|
+ String.k = 0;
|
|
|
+ String.j ++;
|
|
|
+ Flag.DISP_BSY = 1;
|
|
|
+ TIM16->CR1 |= TIM_CR1_CEN; // start tim16 counter
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -316,7 +328,7 @@ void display_WriteBuf(const uint8_t * buf) {
|
|
|
DMA1_Channel3->CMAR = (uint32_t)&spi_buf[0];
|
|
|
#else
|
|
|
/* DMA Source addr: Address of the SPI buffer. */
|
|
|
- DMA1_Channel3->CMAR = (uint32_t)&display_Buffer[0];
|
|
|
+ DMA1_Channel3->CMAR = (uint32_t)&buf[0];
|
|
|
#endif /* FRAMEBUFFER_ROTATE */
|
|
|
|
|
|
/* Set DMA data transfer length (SPI buffer length). */
|
|
@@ -346,3 +358,26 @@ void display_Fill(uint8_t pattern) {
|
|
|
}
|
|
|
display_WriteBuffer();
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief This function handles TIM16 global interrupt.
|
|
|
+ */
|
|
|
+void TIM16_IRQHandler(void) {
|
|
|
+ if (TIM16->SR & TIM_SR_UIF) {
|
|
|
+ TIM16->SR = 0; // reset flag
|
|
|
+
|
|
|
+ display_WriteBuf(&String.Buf[String.k]);
|
|
|
+
|
|
|
+ String.k ++;
|
|
|
+ if (String.k > String.j) {
|
|
|
+ String.k = 0;
|
|
|
+
|
|
|
+ String.Repeat --;
|
|
|
+ if (String.Repeat == 0) {
|
|
|
+ Flag.DISP_BSY = 0;
|
|
|
+ TIM16->CR1 &= ~(TIM_CR1_CEN);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|