Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PololuLedStrip by
PololuLedStrip.cpp@1:102307d9b701, 2013-02-27 (annotated)
- Committer:
- DavidEGrayson
- Date:
- Wed Feb 27 01:43:44 2013 +0000
- Revision:
- 1:102307d9b701
- Child:
- 4:d3b60bd43811
Initial commit.;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DavidEGrayson | 1:102307d9b701 | 1 | #include "PololuLedStrip.h" |
DavidEGrayson | 1:102307d9b701 | 2 | |
DavidEGrayson | 1:102307d9b701 | 3 | bool PololuLedStrip::interruptFriendly = false; |
DavidEGrayson | 1:102307d9b701 | 4 | |
DavidEGrayson | 1:102307d9b701 | 5 | PololuLedStrip::PololuLedStrip(PinName pinName) |
DavidEGrayson | 1:102307d9b701 | 6 | { |
DavidEGrayson | 1:102307d9b701 | 7 | gpio_init(&gpio, pinName, PIN_OUTPUT); |
DavidEGrayson | 1:102307d9b701 | 8 | } |
DavidEGrayson | 1:102307d9b701 | 9 | |
DavidEGrayson | 1:102307d9b701 | 10 | void PololuLedStrip::write(rgb_color * colors, unsigned int count) |
DavidEGrayson | 1:102307d9b701 | 11 | { |
DavidEGrayson | 1:102307d9b701 | 12 | __disable_irq(); // Disable interrupts temporarily because we don't want our pulse timing to be messed up. |
DavidEGrayson | 1:102307d9b701 | 13 | |
DavidEGrayson | 1:102307d9b701 | 14 | while(count--) |
DavidEGrayson | 1:102307d9b701 | 15 | { |
DavidEGrayson | 1:102307d9b701 | 16 | led_strip_write_color(colors++, gpio.reg_set, gpio.reg_clr, gpio.mask); |
DavidEGrayson | 1:102307d9b701 | 17 | |
DavidEGrayson | 1:102307d9b701 | 18 | if (interruptFriendly) |
DavidEGrayson | 1:102307d9b701 | 19 | { |
DavidEGrayson | 1:102307d9b701 | 20 | __enable_irq(); |
DavidEGrayson | 1:102307d9b701 | 21 | __nop(); |
DavidEGrayson | 1:102307d9b701 | 22 | __nop(); |
DavidEGrayson | 1:102307d9b701 | 23 | __nop(); |
DavidEGrayson | 1:102307d9b701 | 24 | __disable_irq(); |
DavidEGrayson | 1:102307d9b701 | 25 | } |
DavidEGrayson | 1:102307d9b701 | 26 | } |
DavidEGrayson | 1:102307d9b701 | 27 | |
DavidEGrayson | 1:102307d9b701 | 28 | __enable_irq(); // Re-enable interrupts now that we are done. |
DavidEGrayson | 1:102307d9b701 | 29 | wait_us(24); // Hold the line low for 24 microseconds to send the reset signal. |
DavidEGrayson | 1:102307d9b701 | 30 | } |