This is an example program for the PololuLedStrip library. It generates a simple moving gradient pattern.
Dependencies: PololuLedStrip mbed LedStripGradient
Dependents: LedStripGradient led_phare_crf
For more information, see the PololuLedStrip library.
Revision 3:f566eea13f49, committed 2013-02-26
- Comitter:
- DavidEGrayson
- Date:
- Tue Feb 26 02:16:59 2013 +0000
- Parent:
- 2:bd6fe6d2948d
- Child:
- 4:27b5c9cafe92
- Commit message:
- Added all the arguments we are going to need
Changed in this revision
led_strip.s | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/led_strip.s Tue Feb 26 02:08:39 2013 +0000 +++ b/led_strip.s Tue Feb 26 02:16:59 2013 +0000 @@ -1,22 +1,13 @@ AREA asm_func, CODE, READONLY -; Export my_asm function location so that C compiler can find it and link - EXPORT my_asm -my_asm -; -; ARM Assembly language function to set LED1 bit to a value passed from C -; LED1 gets value (passed from C compiler in R0) -; LED1 is on GPIO port 1 bit 18 -; See Chapter 9 in the LPC1768 User Manual -; for all of the GPIO register info and addresses -; Pinnames.h has the mbed modules pin port and bit connections -; - push {R9} + EXPORT led_strip_write +led_strip_write + push {R9,R10} LDR R9, =0x2009C020 ; 0x2009C020 = GPIO port 1 base address - MOV.W R2, #0x040000 ; 0x040000 = 1<<18 all "0"s with a "1" in bit 18 - CMP R1, #0 ; value == 0 ? + MOV.W R10, #0x040000 ; 0x040000 = 1<<18 all "0"s with a "1" in bit 18 + CMP R3, #0 ; value == 0 ? ITE EQ - STREQ R2, [R9,#0x1C] ; if==0, clear LED1 bit - STRNE R2, [R9,#0x18] ; if==1, set LED1 bit - pop {R9} + STREQ R10, [R9,#0x1C] ; if==0, clear LED1 bit + STRNE R10, [R9,#0x18] ; if==1, set LED1 bit + pop {R9,R10} BX LR END \ No newline at end of file
--- a/main.cpp Tue Feb 26 02:08:39 2013 +0000 +++ b/main.cpp Tue Feb 26 02:16:59 2013 +0000 @@ -1,9 +1,6 @@ #include "mbed.h" #include "gpio_api.h" -//extern "C" int my_asm(volatile uint32_t * set, int value); -extern "C" int my_asm(int x, int value); - namespace Pololu { #ifndef _POLOLU_RGB_COLOR @@ -14,13 +11,15 @@ } rgb_color; #endif + extern "C" int led_strip_write(rgb_color *, volatile uint32_t * set, volatile uint32_t * clear, uint32_t mask); + class PololuLedStrip { static bool interruptFriendly; public: gpio_t gpio; PololuLedStrip(PinName pin); - void write(rgb_color *, unsigned int count); + void write(rgb_color * colors, unsigned int count); }; bool PololuLedStrip::interruptFriendly; @@ -109,9 +108,9 @@ while(1) { myled2 = 1; - my_asm(0, 1); + led_strip_write(NULL, gpio.reg_set, gpio.reg_clr, 1); wait(0.2); - my_asm(1, 0); + led_strip_write(NULL, gpio.reg_set, gpio.reg_clr, 0); myled2 = 0; wait(1); }