Parcourir la source

Fixed SPI algoritm for 74HC595.

Vladimir N. Shilov il y a 11 mois
Parent
commit
91ac82efe6
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  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);
 }