Probeweise mal mit Flashchip sprechen (Statusregister auslesen)
authorWintermute <wintermute@hannover.ccc.de>
Thu, 10 Oct 2013 20:13:57 +0000 (22:13 +0200)
committerWintermute <wintermute@hannover.ccc.de>
Thu, 10 Oct 2013 20:13:57 +0000 (22:13 +0200)
badge/main.c
badge/ui/display.c

index d72e643..8059155 100644 (file)
@@ -45,6 +45,7 @@
 #include "core/pmu/pmu.h"
 #include "core/wdt/wdt.h"
 #include "core/gpio/gpio.h"
+#include "core/ssp/ssp.h"
 #include "core/systick/systick.h"
 #include "core/usbhid-rom/usbmsc.h"
 
@@ -175,9 +176,10 @@ void rbInit() {
     int pin;
     int value;
   } const output_pins[] = {
-    { RB_PWR_GOOD, 0 },
-    { USB_CONNECT, 1 },
-    { RB_LCD_CS  , 1 },
+    { RB_PWR_GOOD , 0 },
+    { USB_CONNECT , 1 },
+    { RB_LCD_CS   , 1 },
+    { RB_SPI_CS_DF, 1 },
 #if !HW_IS_PROTOTYPE
     { RB_SPI_SS2 , 1 },
     { RB_SPI_SS3 , 1 },
@@ -292,8 +294,22 @@ int main(void)
     }
     case BADGE_EVENT_GAME_TICK: {
       badge_sprite const sp = { 4, 4, (uint8_t const *) "\xff\xff" };
-      badge_framebuffer fb = { { { 0xcc } } };
+      badge_framebuffer fb = { { { 0x80 } } };
 
+      SSP_SSP0CR0 =
+       SSP_SSP0CR0_DSS_8BIT     // Data size = 8-bit
+       | SSP_SSP0CR0_FRF_SPI    // Frame format = SPI
+       | SSP_SSP0CR0_SCR_8;
+
+      gpioSetValue(RB_SPI_CS_DF, 0);
+
+      uint8_t st;
+      sspSend(0, "\x05", 1);
+      sspReceive(0, &st, 1);
+
+      gpioSetValue(RB_SPI_CS_DF, 1);
+
+      fb.data[0][1] = st;
       /*
       for(int i = 0; i < 9 * 96; ++i) {
        fb.data[0][i] = 0xbb;
index e1fb67b..8964900 100644 (file)
@@ -104,8 +104,8 @@ void badge_display_init(void) {
    * 10: set x address (upper bits): X[6-4] = 0
    */
   static uint8_t const initseq[]= { 0xE2, 0xAF, // Display ON
-                                   //0xA1,       // Mirror-X
-                                    0xc8, // mirror-y
+                                   0xA1,       // Mirror-X
+                                    //0xc8, // mirror-y
                                     0xa7, // invert (1 = black)
                                     0xA4, 0x2F,
                                    // 0x9f, 0x24
This page took 0.02288 seconds and 4 git commands to generate.