Skip to content

A few fixes for nRF52840 feather QSPI and neopixel #1354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,21 @@

#define MICROPY_HW_NEOPIXEL (&pin_P0_16)

#ifdef QSPI_FLASH_FILESYSTEM
#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 17)
#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 22)
#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 23)
#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 21)
#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19)
#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 20)
#endif

#ifdef SPI_FLASH_FILESYSTEM
#define SPI_FLASH_MOSI_PIN &pin_P0_17
#define SPI_FLASH_MISO_PIN &pin_P0_22
#define SPI_FLASH_SCK_PIN &pin_P0_19
#define SPI_FLASH_CS_PIN &pin_P0_20
#endif

#define CIRCUITPY_AUTORELOAD_DELAY_MS 500

Expand All @@ -51,8 +60,6 @@

#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)

#define EXTERNAL_FLASH_QSPI_DUAL (1)

#define BOARD_HAS_CRYSTAL 1

#define DEFAULT_I2C_BUS_SCL (&pin_P0_11)
Expand Down
2 changes: 1 addition & 1 deletion ports/nrf/boards/feather_nrf52840_express/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ endif

NRF_DEFINES += -DNRF52840_XXAA -DNRF52840

QSPI_FLASH_FILESYSTEM = 1
SPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = "GD25Q16C"
2 changes: 0 additions & 2 deletions ports/nrf/common-hal/microcontroller/Pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ STATIC uint32_t claimed_pins[GPIO_COUNT];
STATIC uint32_t never_reset_pins[GPIO_COUNT];

void reset_all_pins(void) {
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

for (size_t i = 0; i < GPIO_COUNT; i++) {
claimed_pins[i] = never_reset_pins[i];
}
Expand Down Expand Up @@ -77,7 +76,6 @@ void reset_all_pins(void) {

// Mark pin as free and return it to a quiescent state.
void reset_pin_number(uint8_t pin_number) {
return;
if (pin_number == NO_PIN) {
return;
}
Expand Down
16 changes: 14 additions & 2 deletions ports/nrf/common-hal/neopixel_write/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,21 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
// using DWT
uint32_t pattern_size = numBytes * 8 * sizeof(uint16_t) + 2 * sizeof(uint16_t);
uint16_t* pixels_pattern = NULL;
bool pattern_on_heap = false;

// Use the stack to store 1 pixels worth of PWM data for the status led. uint32_t to ensure alignment.
uint32_t one_pixel[8 * sizeof(uint16_t) + 1];

NRF_PWM_Type* pwm = find_free_pwm();

// only malloc if there is PWM device available
if ( pwm != NULL ) {
pixels_pattern = (uint16_t *) m_malloc(pattern_size, false);
if (numBytes == 4) {
pixels_pattern = (uint16_t *) one_pixel;
} else {
pixels_pattern = (uint16_t *) m_malloc_maybe(pattern_size, false);
pattern_on_heap = true;
}
}

// Use the identified device to choose the implementation
Expand Down Expand Up @@ -193,7 +202,10 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
nrf_pwm_disable(pwm);
nrf_pwm_pins_set(pwm, (uint32_t[]) {0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL} );

m_free(pixels_pattern);
if (pattern_on_heap) {
m_free(pixels_pattern);
}

} // End of DMA implementation
// ---------------------------------------------------------------------
else {
Expand Down