Skip to content

Commit eefbe6b

Browse files
authored
Merge pull request #337 from adafruit/support-itsybitsy-dotstar
support itsybitsy dotstar led
2 parents 488711a + ab74be4 commit eefbe6b

File tree

6 files changed

+160
-11
lines changed

6 files changed

+160
-11
lines changed

Makefile

+8-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ OUT_NAME = $(BOARD)_bootloader-$(GIT_VERSION)
4949
# merged file = compiled + sd
5050
MERGED_FILE = $(OUT_NAME)_$(SD_NAME)_$(SD_VERSION)
5151

52+
UF2_FAMILY_ID_BOOTLOADER = 0xd663823c
53+
5254
#------------------------------------------------------------------------------
5355
# Tool Configure
5456
#------------------------------------------------------------------------------
@@ -435,7 +437,7 @@ $(BUILD)/$(OUT_NAME)_nosd.hex: $(BUILD)/$(OUT_NAME).hex
435437
# Bootolader self-update uf2
436438
$(BUILD)/update-$(OUT_NAME)_nosd.uf2: $(BUILD)/$(OUT_NAME)_nosd.hex
437439
@echo Create $(notdir $@)
438-
@python3 lib/uf2/utils/uf2conv.py -f 0xd663823c -c -o $@ $^
440+
@python3 lib/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID_BOOTLOADER) -c -o $@ $^
439441

440442
# merge bootloader and sd hex together
441443
$(BUILD)/$(MERGED_FILE).hex: $(BUILD)/$(OUT_NAME).hex
@@ -488,6 +490,11 @@ flash-mbr:
488490
@echo Flashing: $(MBR_HEX)
489491
$(call FLASH_NOUICR_CMD,$(MBR_HEX))
490492

493+
# flash using uf2
494+
flash-uf2: $(BUILD)/update-$(OUT_NAME)_nosd.uf2
495+
@echo Flashing: $(notdir $<)
496+
python lib/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID_BOOTLOADER) --deploy $<
497+
491498
# dfu with adafruit-nrfutil using CDC interface
492499
dfu-flash: flash-dfu
493500
flash-dfu: $(BUILD)/$(MERGED_FILE).zip

src/boards/boards.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
#include "app_scheduler.h"
2828
#include "app_timer.h"
2929

30-
#ifdef LED_APA102
30+
#ifdef LED_APA102_CLK
3131
#include "nrf_spim.h"
3232
#endif
3333

3434
#define SCHED_MAX_EVENT_DATA_SIZE sizeof(app_timer_event_t) /**< Maximum size of scheduler events. */
3535
#define SCHED_QUEUE_SIZE 30 /**< Maximum number of events in the scheduler queue. */
3636

37-
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
37+
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102_CLK)
3838
void neopixel_init(void);
3939
void neopixel_write(uint8_t* pixels);
4040
void neopixel_teardown(void);
@@ -86,7 +86,7 @@ void board_init(void) {
8686
#endif
8787
#endif
8888

89-
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
89+
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102_CLK)
9090
// use neopixel for use enumeration
9191
#ifdef NEOPIXEL_POWER_PIN
9292
nrf_gpio_cfg_output(NEOPIXEL_POWER_PIN);
@@ -147,7 +147,7 @@ void board_teardown(void) {
147147
led_pwm_teardown();
148148
#endif
149149

150-
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
150+
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102_CLK)
151151
neopixel_teardown();
152152
#endif
153153

@@ -362,7 +362,7 @@ static uint32_t primary_cycle_length;
362362
static uint32_t secondary_cycle_length;
363363
#endif
364364

365-
void led_tick() {
365+
void led_tick(void) {
366366
uint32_t millis = _systick_count;
367367

368368
uint32_t cycle = millis % primary_cycle_length;
@@ -452,7 +452,7 @@ void led_state(uint32_t state) {
452452
final_color = (uint8_t*) &rgb_color;
453453
}
454454

455-
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102)
455+
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN) || defined(LED_APA102_CLK)
456456
if (final_color != NULL) {
457457
neopixel_write(final_color);
458458
}
@@ -560,7 +560,7 @@ void neopixel_write(uint8_t* pixels) {
560560

561561
#endif
562562

563-
#ifdef LED_APA102
563+
#ifdef LED_APA102_CLK
564564
#define BYTE_PER_PIXEL 4
565565

566566
// 4 zero bytes are required to initiate update
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(MCU_VARIANT nrf52840)

src/boards/itsybitsy_nrf52840_express/board.h

+8-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@
3434
#define LED_PRIMARY_PIN _PINNUM(0, 6)
3535
#define LED_STATE_ON 1
3636

37-
#define LED_NEOPIXEL _PINNUM(0, 8)
38-
#define NEOPIXELS_NUMBER 1
39-
#define BOARD_RGB_BRIGHTNESS 0x040404
37+
#define LED_APA102_CLK _PINNUM(1, 9)
38+
#define LED_APA102_DATA _PINNUM(0, 8)
39+
#define LED_APA102_BRIGHTNESS 0x1
40+
#define APA102_NUMBER 1
41+
42+
// For dotstart set to max for colour information is not masked off
43+
#define BOARD_RGB_BRIGHTNESS 0xffffffff
44+
4045

4146
/*------------------------------------------------------------------*/
4247
/* BUTTON

src/nrfx_config.h

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#define NRFX_PRS_ENABLED 0
1212

13+
// PWM
1314
#define NRFX_PWM_ENABLED 0
1415
#define NRFX_PWM0_ENABLED 0
1516
#define NRFX_PWM1_ENABLED 0

src/nrfx_log.h

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/*
2+
* Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
*
15+
* 3. Neither the name of the copyright holder nor the names of its
16+
* contributors may be used to endorse or promote products derived from this
17+
* software without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29+
* POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
32+
#ifndef NRFX_LOG_H__
33+
#define NRFX_LOG_H__
34+
35+
// THIS IS A TEMPLATE FILE.
36+
// It should be copied to a suitable location within the host environment into
37+
// which nrfx is integrated, and the following macros should be provided with
38+
// appropriate implementations.
39+
// And this comment should be removed from the customized file.
40+
41+
#ifdef __cplusplus
42+
extern "C" {
43+
#endif
44+
45+
/**
46+
* @defgroup nrfx_log nrfx_log.h
47+
* @{
48+
* @ingroup nrfx
49+
*
50+
* @brief This file contains macros that should be implemented according to
51+
* the needs of the host environment into which @em nrfx is integrated.
52+
*/
53+
54+
/**
55+
* @brief Macro for logging a message with the severity level ERROR.
56+
*
57+
* @param format printf-style format string, optionally followed by arguments
58+
* to be formatted and inserted in the resulting string.
59+
*/
60+
#define NRFX_LOG_ERROR(format, ...)
61+
62+
/**
63+
* @brief Macro for logging a message with the severity level WARNING.
64+
*
65+
* @param format printf-style format string, optionally followed by arguments
66+
* to be formatted and inserted in the resulting string.
67+
*/
68+
#define NRFX_LOG_WARNING(format, ...)
69+
70+
/**
71+
* @brief Macro for logging a message with the severity level INFO.
72+
*
73+
* @param format printf-style format string, optionally followed by arguments
74+
* to be formatted and inserted in the resulting string.
75+
*/
76+
#define NRFX_LOG_INFO(format, ...)
77+
78+
/**
79+
* @brief Macro for logging a message with the severity level DEBUG.
80+
*
81+
* @param format printf-style format string, optionally followed by arguments
82+
* to be formatted and inserted in the resulting string.
83+
*/
84+
#define NRFX_LOG_DEBUG(format, ...)
85+
86+
87+
/**
88+
* @brief Macro for logging a memory dump with the severity level ERROR.
89+
*
90+
* @param[in] p_memory Pointer to the memory region to be dumped.
91+
* @param[in] length Length of the memory region in bytes.
92+
*/
93+
#define NRFX_LOG_HEXDUMP_ERROR(p_memory, length)
94+
95+
/**
96+
* @brief Macro for logging a memory dump with the severity level WARNING.
97+
*
98+
* @param[in] p_memory Pointer to the memory region to be dumped.
99+
* @param[in] length Length of the memory region in bytes.
100+
*/
101+
#define NRFX_LOG_HEXDUMP_WARNING(p_memory, length)
102+
103+
/**
104+
* @brief Macro for logging a memory dump with the severity level INFO.
105+
*
106+
* @param[in] p_memory Pointer to the memory region to be dumped.
107+
* @param[in] length Length of the memory region in bytes.
108+
*/
109+
#define NRFX_LOG_HEXDUMP_INFO(p_memory, length)
110+
111+
/**
112+
* @brief Macro for logging a memory dump with the severity level DEBUG.
113+
*
114+
* @param[in] p_memory Pointer to the memory region to be dumped.
115+
* @param[in] length Length of the memory region in bytes.
116+
*/
117+
#define NRFX_LOG_HEXDUMP_DEBUG(p_memory, length)
118+
119+
120+
/**
121+
* @brief Macro for getting the textual representation of a given error code.
122+
*
123+
* @param[in] error_code Error code.
124+
*
125+
* @return String containing the textual representation of the error code.
126+
*/
127+
#define NRFX_LOG_ERROR_STRING_GET(error_code)
128+
129+
/** @} */
130+
131+
#ifdef __cplusplus
132+
}
133+
#endif
134+
135+
#endif // NRFX_LOG_H__

0 commit comments

Comments
 (0)