Skip to content

Commit

Permalink
Fix 400/800 KHz check
Browse files Browse the repository at this point in the history
refactor apollo3 c to c++
  • Loading branch information
csonsino committed Sep 9, 2019
1 parent 1642d7f commit 7e182a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
9 changes: 0 additions & 9 deletions Adafruit_NeoPixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,6 @@ extern "C" void espShow(
uint16_t pin, uint8_t *pixels, uint32_t numBytes, uint8_t type);
#endif // ESP8266

#if defined (AM_PART_APOLLO3)
extern "C" void apollo3UnsetPin(
uint16_t pin);
extern "C" void apollo3SetPin(
uint16_t pin);
extern "C" void apollo3Show(
uint16_t pin, uint8_t *pixels, uint32_t numBytes, uint8_t type);
#endif // AM_PART_APOLLO3

/*!
@brief Transmit pixel data in RAM to NeoPixels.
@note On most architectures, interrupts are temporarily disabled in
Expand Down
6 changes: 6 additions & 0 deletions Adafruit_NeoPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ class Adafruit_NeoPixel {

protected:

#if defined (AM_PART_APOLLO3)
void apollo3UnsetPin(uint16_t pin);
void apollo3SetPin(uint16_t pin);
void apollo3Show(uint16_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz);
#endif // AM_PART_APOLLO3

#ifdef NEO_KHZ400 // If 400 KHz NeoPixel support enabled...
boolean is800KHz; ///< true if 800 KHz pixels
#endif
Expand Down
12 changes: 7 additions & 5 deletions apollo3.c → apollo3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <ap3_types.h>
#include <am_hal_gpio.h>

#include "Adafruit_NeoPixel.h"

// The timing method used to control the NeoPixels
// TODO: Implement something better (interrupts, DMA, etc)
#define PIN_METHOD_FAST_GPIO
Expand All @@ -13,7 +15,7 @@
@brief Unset the NeoPixel output pin number.
@param p Arduino pin number (-1 = no pin).
*/
void apollo3UnsetPin(uint16_t pin) {
void Adafruit_NeoPixel::apollo3UnsetPin(uint16_t pin) {
#if defined(PIN_METHOD_FAST_GPIO)
// Unconfigure the pin for Fast GPIO.
am_hal_gpio_fastgpio_disable(pin);
Expand All @@ -24,7 +26,7 @@ void apollo3UnsetPin(uint16_t pin) {
@brief Set the NeoPixel output pin number.
@param p Arduino pin number (-1 = no pin).
*/
void apollo3SetPin(uint16_t pin) {
void Adafruit_NeoPixel::apollo3SetPin(uint16_t pin) {
#if defined(PIN_METHOD_FAST_GPIO)
// Configure the pin to be used for Fast GPIO.
am_hal_gpio_fastgpio_disable(pin);
Expand All @@ -49,8 +51,8 @@ void apollo3SetPin(uint16_t pin) {
@note The current design is a quick hack and should be replaced with
a more robust timing mechanism.
*/
void apollo3Show(
uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) {
void Adafruit_NeoPixel::apollo3Show(
uint16_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) {

uint8_t *ptr, *end, p, bitMask;
ptr = pixels;
Expand Down Expand Up @@ -91,7 +93,7 @@ void apollo3Show(
}
#ifdef NEO_KHZ400
} else { // 400 KHz bitstream
// NOTE - These timings probably need to be tweaked
// NOTE - These timings may need to be tweaked
for(;;) {
am_hal_gpio_fastgpio_set(pin);
//asm("nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop;");
Expand Down

0 comments on commit 7e182a8

Please sign in to comment.