瀏覽代碼

Fixed SPI algoritm for 74HC595.

Vladimir N. Shilov 11 月之前
父節點
當前提交
91ac82efe6
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      lib/led.c

+ 5 - 1
lib/led.c

@@ -12,7 +12,7 @@
 uint8_t LedDigits[LED_DIGITS_NUM] = {0xff}; // digits to dsplay
 uint8_t LedPoint[LED_DIGITS_NUM] = {0, 1, 0, 0, 0, 0, 0, 1}; // dots for digits
 /*                                                 1     2     3     4     5     6     7     8 */
-static const uint8_t led_num[LED_DIGITS_NUM] = {0x10, 0x08, 0x04, 0x02, 0x20, 0x40, 0x80, 0x01};
+static const uint8_t led_num[LED_DIGITS_NUM] = {0x08, 0x04, 0x02, 0x01, 0x10, 0x20, 0x40, 0x80};
 
 static void led_SelectDigit (const uint8_t pos);
 
@@ -127,4 +127,8 @@ static void led_SelectDigit (const uint8_t pos) {
     GPIO_HIGH(SPI_PORT, SPI_SCK); // shift bit
     data <<= 1;
   }
+  /* hack for LATCH */
+  GPIO_LOW(SPI_PORT, SPI_DATA);
+  GPIO_LOW(SPI_PORT, SPI_SCK);
+  GPIO_HIGH(SPI_PORT, SPI_SCK);
 }