Simple 8x8 LED Matrix controller which interfaces with a Processing GUI over serial to display sketches

Dependencies:   Multi_WS2811 mbed

Fork of Multi_WS2811_test by Ned Konz

Files at this revision

API Documentation at this revision

Comitter:
heroic
Date:
Thu Oct 10 21:52:59 2013 +0000
Parent:
14:c97261a9a282
Child:
17:b4e9d8f4baa9
Commit message:
Bump version, add register debug.

Changed in this revision

WS2811.cpp Show annotated file Show diff for this revision Revisions of this file
bitband.h Show annotated file Show diff for this revision Revisions of this file
--- a/WS2811.cpp	Sun Jul 28 08:38:18 2013 +0000
+++ b/WS2811.cpp	Thu Oct 10 21:52:59 2013 +0000
@@ -6,6 +6,7 @@
 
 #include "LedStrip.h"
 #include "WS2811.h"
+#include "bitband.h"
 
 extern int onewire_speed_multiplier;   // speed setting for ws2811 et al.
 
@@ -36,6 +37,9 @@
     clock_set = clk.get_set();
     clock_clr = clk.get_clr();
     
+    printf("ws2811:          data mask 0x%x, data set reg 0x%x, data clear reg 0x%x\r\n", data_mask, data_set, data_clr);
+    printf("ws2811: (unused) clock mask 0x%x, clock set reg 0x%x, clock clear reg 0x%x\r\n", clock_mask, clock_set, clock_clr);
+    
 }
 
 /*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bitband.h	Thu Oct 10 21:52:59 2013 +0000
@@ -0,0 +1,71 @@
+//*****************************************************************************
+//   +--+
+//   | ++----+
+//   +-++    |
+//     |     |
+//   +-+--+  |
+//   | +--+--+
+//   +----+    Copyright (c) 2011 Code Red Technologies Ltd.
+//
+// Header file containing C macros to provide bitbanding on Cortex-M3 MCU's
+//
+// Software License Agreement
+//
+// The software is owned by Code Red Technologies and/or its suppliers, and is
+// protected under applicable copyright laws.  All rights are reserved.  Any
+// use in violation of the foregoing restrictions may subject the user to criminal
+// sanctions under applicable laws, as well as to civil liability for the breach
+// of the terms and conditions of this license.
+//
+// THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
+// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
+// USE OF THIS SOFTWARE FOR COMMERCIAL DEVELOPMENT AND/OR EDUCATION IS SUBJECT
+// TO A CURRENT END USER LICENSE AGREEMENT (COMMERCIAL OR EDUCATIONAL) WITH
+// CODE RED TECHNOLOGIES LTD.
+//
+//*****************************************************************************
+
+#ifndef BITBAND_H_
+#define BITBAND_H_
+
+/* The Cortex-M3 memory map includes two bit-band regions. These occupy the lowest
+ * 1MB of the SRAM and peripheral memory regions respectively.
+ * + SRAM:  Bit-band region:    0x20000000 - 0x20100000
+ *          Bit-band alias:     0x22000000 - 0x23FFFFFF
+ * + PERI:  Bit-band region:    0x40000000 - 0x40100000
+ *          Bit-band alias:     0x42000000 - 0x43FFFFFF
+ * The mapping formula:
+ *      bit_word_offset = (byte_offset * 32) + (bit_number * 4)
+ *      bit_word_address = bit_band_base + bit_word_offset
+ * where:
+ *  + bit_word_offset: the position of the target bit in the bit-band memory region
+ *  + bit_word_addr: the address of the word in the alias memory region that maps to the target bit
+ *  + bit_band_base: the starting address of the alias region
+ *  + byte_offset: the number of byte in the bit-band region that contains the targeted bit
+ *  + bit_number: is the bit position (0-7) of the targeted bit
+ */
+
+/* Bit band SRAM definitions */
+#define BITBAND_SRAM_REF   0x20000000
+#define BITBAND_SRAM_BASE  0x22000000
+
+#define BITBAND_SRAM(a,b) ((BITBAND_SRAM_BASE + ((a-BITBAND_SRAM_REF)<<5) + (b<<2)))  // Convert SRAM address
+
+/* Bit band PERIPHERAL definitions */
+#define BITBAND_PERI_REF   0x40000000
+#define BITBAND_PERI_BASE  0x42000000
+
+#define BITBAND_PERI(a,b) ((BITBAND_PERI_BASE + ((a-BITBAND_PERI_REF)<<5) + (b<<2)))  // Convert PERI address
+
+/* Basic bit band function definitions */
+#define BITBAND_SRAM_ClearBit(a,b)  (*(volatile uint32_t *) (BITBAND_SRAM(a,b)) = 0)
+#define BITBAND_SRAM_SetBit(a,b)    (*(volatile uint32_t *) (BITBAND_SRAM(a,b)) = 1)
+#define BITBAND_SRAM_GetBit(a,b)    (*(volatile uint32_t *) (BITBAND_SRAM(a,b)))
+
+#define BITBAND_PERI_ClearBit(a,b)  (*(volatile uint32_t *) (BITBAND_PERI(a,b)) = 0)
+#define BITBAND_PERI_SetBit(a,b)    (*(volatile uint32_t *) (BITBAND_PERI(a,b)) = 1)
+#define BITBAND_PERI_GetBit(a,b)    (*(volatile uint32_t *) (BITBAND_PERI(a,b)))
+
+
+#endif /* BITBAND_H_ */