TG-LPC11U35-501に対応

Dependencies:   mbed

こちらのページのプログラムを、TG-LPC11U35-501に対応させました。
https://developer.mbed.org/users/tkasa/code/LEDTape_WS2812/wiki/Homepage

動作に疑問があるため、教えを請うための公開です。
疑問が解消され次第公開を終了します。

(2016/04/13 追記)
おかしな動作解消されました。

プログラム LEDstrip_WS2812.cpp を修正しました。
修正点はコメントを加えてあります。

しばらくしたら、削除する予定です。

Committer:
hirobe0913
Date:
Wed Apr 13 06:52:12 2016 +0000
Revision:
2:ebd3f4b4e0a3
Parent:
1:4aff1ebb42c1
????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hirobe0913 0:4b0686730a99 1 /*
hirobe0913 0:4b0686730a99 2 * WS2812 tape led IC
hirobe0913 0:4b0686730a99 3 */
hirobe0913 0:4b0686730a99 4 #include "mbed.h"
hirobe0913 0:4b0686730a99 5 #include "LEDStrip.h"
hirobe0913 0:4b0686730a99 6
hirobe0913 0:4b0686730a99 7
hirobe0913 0:4b0686730a99 8 #if defined(TARGET_LPC1768)
hirobe0913 0:4b0686730a99 9 Serial pc(USBTX, USBRX);
hirobe0913 0:4b0686730a99 10 #elif defined(TARGET_LPC11U35_501)
hirobe0913 0:4b0686730a99 11 Serial pc(p9, p10);
hirobe0913 0:4b0686730a99 12 #endif
hirobe0913 0:4b0686730a99 13 DigitalOut led1(LED1), led2(LED2); // , led3(LED3), led4(LED4);
hirobe0913 0:4b0686730a99 14
hirobe0913 0:4b0686730a99 15 extern "C"
hirobe0913 0:4b0686730a99 16 void HardFault_Handler() {
hirobe0913 0:4b0686730a99 17 printf("Hard Fault!\r\n");
hirobe0913 0:4b0686730a99 18 exit(-1);
hirobe0913 0:4b0686730a99 19 }
hirobe0913 0:4b0686730a99 20
hirobe0913 0:4b0686730a99 21 int main() {
hirobe0913 0:4b0686730a99 22 int j, k = 0;
hirobe0913 0:4b0686730a99 23 int vall[4];
hirobe0913 0:4b0686730a99 24
hirobe0913 0:4b0686730a99 25 pc.baud(115200);
hirobe0913 0:4b0686730a99 26 tapeInit(0, 16);
hirobe0913 0:4b0686730a99 27 led1 = 1;
hirobe0913 0:4b0686730a99 28
hirobe0913 0:4b0686730a99 29 pc.printf("led\r\n");
hirobe0913 0:4b0686730a99 30
hirobe0913 0:4b0686730a99 31 for (;;) {
hirobe0913 0:4b0686730a99 32 for (long int i = 0; i < 128; i++) {
hirobe0913 0:4b0686730a99 33 vall[0] = (i << 8)|(127-i);
hirobe0913 0:4b0686730a99 34 vall[1] = (i << 16)|((127-i)<<8);
hirobe0913 0:4b0686730a99 35 vall[2] = ((127-i)<<16)|i;
hirobe0913 1:4aff1ebb42c1 36 // vall[3] = i;
hirobe0913 1:4aff1ebb42c1 37 vall[3] = ((127-i)<<16)|(127-i);
hirobe0913 0:4b0686730a99 38 for(int j=0;j<4;j++){
hirobe0913 0:4b0686730a99 39 // j = 0;
hirobe0913 0:4b0686730a99 40 tapeSet(j, vall[j]);
hirobe0913 0:4b0686730a99 41 tapeSend();
hirobe0913 0:4b0686730a99 42 wait(0.1);
hirobe0913 0:4b0686730a99 43 pc.printf("i= %d\r\n",i);
hirobe0913 0:4b0686730a99 44 }
hirobe0913 0:4b0686730a99 45 wait_ms(2);
hirobe0913 0:4b0686730a99 46 }
hirobe0913 0:4b0686730a99 47 }
hirobe0913 0:4b0686730a99 48
hirobe0913 1:4aff1ebb42c1 49 /*
hirobe0913 0:4b0686730a99 50 for (;;) {
hirobe0913 0:4b0686730a99 51 for (long int i = 0; i < 256; i++) {
hirobe0913 0:4b0686730a99 52 int val = (i << 8)|(255-i);
hirobe0913 0:4b0686730a99 53 for(int j=0;j<16;j++){
hirobe0913 0:4b0686730a99 54 tapeSet(j, val);
hirobe0913 0:4b0686730a99 55 }
hirobe0913 0:4b0686730a99 56 tapeSend();
hirobe0913 0:4b0686730a99 57 wait_ms(2);
hirobe0913 0:4b0686730a99 58 }
hirobe0913 0:4b0686730a99 59 for (long int i = 0; i < 256; i++) {
hirobe0913 0:4b0686730a99 60 int val = (i << 16)|((255-i)<<8);
hirobe0913 0:4b0686730a99 61 for(int j=0;j<16;j++){
hirobe0913 0:4b0686730a99 62 tapeSet(j, val);
hirobe0913 0:4b0686730a99 63 }
hirobe0913 0:4b0686730a99 64 tapeSend();
hirobe0913 0:4b0686730a99 65 wait_ms(2);
hirobe0913 0:4b0686730a99 66 }
hirobe0913 0:4b0686730a99 67 for (long int i = 0; i < 256; i++) {
hirobe0913 0:4b0686730a99 68 int val = ((255-i)<<16)|i;
hirobe0913 0:4b0686730a99 69 for(int j=0;j<16;j++){
hirobe0913 0:4b0686730a99 70 tapeSet(j, val);
hirobe0913 0:4b0686730a99 71 }
hirobe0913 0:4b0686730a99 72 tapeSend();
hirobe0913 0:4b0686730a99 73 wait_ms(2);
hirobe0913 0:4b0686730a99 74
hirobe0913 0:4b0686730a99 75 }
hirobe0913 0:4b0686730a99 76 pc.printf("test3\r\n");
hirobe0913 0:4b0686730a99 77 // while (1);
hirobe0913 0:4b0686730a99 78 for (long int i = 0; i < 160; i ++) {
hirobe0913 0:4b0686730a99 79 tapeSet(i, 0);
hirobe0913 0:4b0686730a99 80 }
hirobe0913 0:4b0686730a99 81 tapeSend();
hirobe0913 0:4b0686730a99 82 }
hirobe0913 1:4aff1ebb42c1 83 */
hirobe0913 0:4b0686730a99 84
hirobe0913 0:4b0686730a99 85 }