Skip to content

Commit c3fc0db

Browse files
committed
Merge branch 'master' into develop
2 parents b1029c6 + a921f27 commit c3fc0db

File tree

7 files changed

+121
-35
lines changed

7 files changed

+121
-35
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ For other boards, please check the board definition for details.
7676

7777
### Making your own UF2
7878

79-
To create your own UF2 DFU update image, simply use the [Python conversion script](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py) on a .bin file or .hex file, specifying the family as **0xADA52840**. Be sure to compile your application to start at 0x26000 (152k). If using a .bin file with the conversion script you must specify this with the -b switch.
79+
To create your own UF2 DFU update image, simply use the [Python conversion script](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py) on a .bin file or .hex file, specifying the family as **0xADA52840**. If using a .bin file with the conversion script you must specify application address with the -b switch, this address depend on the SoftDevice size/version e.g S140 v6 is 0x26000
8080

8181
To create a UF2 image from a .bin file:
8282
```

src/boards.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
#define SCHED_QUEUE_SIZE 30 /**< Maximum number of events in the scheduler queue. */
3535

3636
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
37+
void neopixel_init(void);
3738
void neopixel_write(uint8_t *pixels);
39+
void neopixel_teardown(void);
3840
#endif
3941

4042
//------------- IMPLEMENTATION -------------//
@@ -67,9 +69,8 @@ void board_init(void)
6769
led_pwm_init(LED_SECONDARY, LED_SECONDARY_PIN);
6870
#endif
6971

70-
// use neopixel for use enumeration
72+
// use neopixel for use enumeration
7173
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
72-
extern void neopixel_init(void);
7374
neopixel_init();
7475
#endif
7576

@@ -93,7 +94,6 @@ void board_teardown(void)
9394
led_pwm_teardown();
9495

9596
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
96-
extern void neopixel_teardown(void);
9797
neopixel_teardown();
9898
#endif
9999
// Button
@@ -297,9 +297,9 @@ void led_state(uint32_t state)
297297
#define MAGIC_T1H 13UL | (0x8000) // 0.8125us
298298
#define CTOPVAL 20UL // 1.25us
299299

300-
#define NEO_NUMBYTE 3
300+
#define BYTE_PER_PIXEL 3
301301

302-
static uint16_t pixels_pattern[NEO_NUMBYTE * 8 + 2];
302+
static uint16_t pixels_pattern[NEOPIXELS_NUMBER*BYTE_PER_PIXEL * 8 + 2];
303303

304304
// use PWM1 for neopixel
305305
void neopixel_init(void)
@@ -347,29 +347,35 @@ void neopixel_init(void)
347347

348348
void neopixel_teardown(void)
349349
{
350-
uint8_t grb[3] = { 0, 0, 0 };
350+
uint8_t rgb[3] = { 0, 0, 0 };
351351

352352
NRFX_DELAY_US(50); // wait for previous write is complete
353353

354-
neopixel_write(grb);
354+
neopixel_write(rgb);
355355
NRFX_DELAY_US(50); // wait for this write
356356

357357
pwm_teardown(NRF_PWM1);
358358
}
359359

360-
// write 3 bytes color to a built-in neopixel
360+
// write 3 bytes color RGB to built-in neopixel
361361
void neopixel_write (uint8_t *pixels)
362362
{
363-
uint8_t grb[NEO_NUMBYTE] = {pixels[1], pixels[2], pixels[0]};
363+
// convert RGB to GRB
364+
uint8_t grb[BYTE_PER_PIXEL] = {pixels[1], pixels[2], pixels[0]};
364365
uint16_t pos = 0; // bit position
365-
for ( uint16_t n = 0; n < NEO_NUMBYTE; n++ )
366-
{
367-
uint8_t pix = grb[n];
368366

369-
for ( uint8_t mask = 0x80; mask > 0; mask >>= 1 )
367+
// Set all neopixel to same value
368+
for (uint16_t n = 0; n < NEOPIXELS_NUMBER; n++ )
369+
{
370+
for(uint8_t c = 0; c < BYTE_PER_PIXEL; c++)
370371
{
371-
pixels_pattern[pos] = (pix & mask) ? MAGIC_T1H : MAGIC_T0H;
372-
pos++;
372+
uint8_t const pix = grb[c];
373+
374+
for ( uint8_t mask = 0x80; mask > 0; mask >>= 1 )
375+
{
376+
pixels_pattern[pos] = (pix & mask) ? MAGIC_T1H : MAGIC_T0H;
377+
pos++;
378+
}
373379
}
374380
}
375381

@@ -409,8 +415,8 @@ void neopixel_init(void)
409415

410416
void neopixel_teardown(void)
411417
{
412-
uint8_t grb[3] = { 0, 0, 0 };
413-
neopixel_write(grb);
418+
uint8_t rgb[3] = { 0, 0, 0 };
419+
neopixel_write(rgb);
414420
nrf_gpio_cfg_default(LED_RGB_RED_PIN);
415421
nrf_gpio_cfg_default(LED_RGB_GREEN_PIN);
416422
nrf_gpio_cfg_default(LED_RGB_BLUE_PIN);

src/boards/circuitplayground_nrf52840/board.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,24 @@
3232
*------------------------------------------------------------------*/
3333
#define LEDS_NUMBER 1
3434
#define LED_PRIMARY_PIN _PINNUM(1, 14)
35+
#define LED_STATE_ON 1
36+
3537
#define LED_NEOPIXEL _PINNUM(0, 13)
3638
#define NEOPIXELS_NUMBER 10
3739
#define BOARD_RGB_BRIGHTNESS 0x040404
38-
#define LED_STATE_ON 1
3940

4041
/*------------------------------------------------------------------*/
4142
/* BUTTON
4243
*------------------------------------------------------------------*/
4344
#define BUTTONS_NUMBER 2
44-
#define BUTTON_1 _PINNUM(1, 01) // left button
45+
#define BUTTON_1 _PINNUM(1, 02) // left button
4546
#define BUTTON_2 _PINNUM(1, 15) // right button
46-
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
47+
#define BUTTON_PULL NRF_GPIO_PIN_PULLDOWN
4748

4849
/*------------------------------------------------------------------*/
4950
/* UART
5051
*------------------------------------------------------------------*/
51-
#define RX_PIN_NUMBER _PINNUM(0, 29)
52+
#define RX_PIN_NUMBER _PINNUM(0, 30)
5253
#define TX_PIN_NUMBER _PINNUM(0, 14)
5354
#define CTS_PIN_NUMBER 0
5455
#define RTS_PIN_NUMBER 0
@@ -68,7 +69,7 @@
6869
//------------- UF2 -------------//
6970
#define UF2_PRODUCT_NAME "Adafruit Circuit Playground nRF52840"
7071
#define UF2_VOLUME_LABEL "CPLAYBTBOOT"
71-
#define UF2_BOARD_ID "CircuitPlayground-nRF52840-revD"
72+
#define UF2_BOARD_ID "nRF52840-CircuitPlayground-revD"
7273
#define UF2_INDEX_URL "https://www.adafruit.com/product/4300"
7374

74-
#endif // _FEATHER_NRF52840_H
75+
#endif // _CPLAY_NRF52840_H

src/boards/feather_nrf52840_express/board.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@
3333
#define LEDS_NUMBER 2
3434
#define LED_PRIMARY_PIN _PINNUM(1, 15)
3535
#define LED_SECONDARY_PIN _PINNUM(1, 10)
36-
#define LED_NEOPIXEL 16
37-
#define BOARD_RGB_BRIGHTNESS 0x040404
3836
#define LED_STATE_ON 1
3937

38+
#define LED_NEOPIXEL _PINNUM(0, 16)
39+
#define NEOPIXELS_NUMBER 1
40+
#define BOARD_RGB_BRIGHTNESS 0x040404
41+
4042
/*------------------------------------------------------------------*/
4143
/* BUTTON
4244
*------------------------------------------------------------------*/
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2018 Ha Thach for Adafruit Industries
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
#ifndef _ITSYBITSY_NRF52840_H
26+
#define _ITSYBITSY_NRF52840_H
27+
28+
#define _PINNUM(port, pin) ((port)*32 + (pin))
29+
30+
/*------------------------------------------------------------------*/
31+
/* LED
32+
*------------------------------------------------------------------*/
33+
#define LEDS_NUMBER 1
34+
#define LED_PRIMARY_PIN _PINNUM(0, 6)
35+
#define LED_STATE_ON 1
36+
37+
#define LED_NEOPIXEL _PINNUM(0, 8)
38+
#define NEOPIXELS_NUMBER 1
39+
#define BOARD_RGB_BRIGHTNESS 0x040404
40+
41+
/*------------------------------------------------------------------*/
42+
/* BUTTON
43+
*------------------------------------------------------------------*/
44+
#define BUTTONS_NUMBER 2
45+
#define BUTTON_1 _PINNUM(0, 29) // user switch
46+
#define BUTTON_2 _PINNUM(1, 02) // D2 breakout
47+
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
48+
49+
/*------------------------------------------------------------------*/
50+
/* UART
51+
*------------------------------------------------------------------*/
52+
#define RX_PIN_NUMBER _PINNUM(0, 25)
53+
#define TX_PIN_NUMBER _PINNUM(0, 24)
54+
#define CTS_PIN_NUMBER 0
55+
#define RTS_PIN_NUMBER 0
56+
#define HWFC false
57+
58+
// Used as model string in OTA mode
59+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
60+
#define BLEDIS_MODEL "ItsyBitsy nRF52840 Express"
61+
62+
//--------------------------------------------------------------------+
63+
// USB
64+
//--------------------------------------------------------------------+
65+
#define USB_DESC_VID 0x239A
66+
#define USB_DESC_UF2_PID 0x0051
67+
#define USB_DESC_CDC_ONLY_PID 0x0052
68+
69+
//------------- UF2 -------------//
70+
#define UF2_PRODUCT_NAME "Adafruit ItsyBitsy nRF52840 Express"
71+
#define UF2_VOLUME_LABEL "ITSY840BOOT"
72+
#define UF2_BOARD_ID "nRF52840-ItsyBitsy-revA"
73+
#define UF2_INDEX_URL "https://www.adafruit.com/"
74+
75+
#endif // _ITSY_NRF52840_H

src/boards/metro_nrf52840_express/board.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@
3333
#define LEDS_NUMBER 2
3434
#define LED_PRIMARY_PIN _PINNUM(1, 13)
3535
#define LED_SECONDARY_PIN _PINNUM(1, 15)
36+
#define LED_STATE_ON 1
37+
3638
#define LED_NEOPIXEL _PINNUM(0, 13)
39+
#define NEOPIXELS_NUMBER 1
3740
#define BOARD_RGB_BRIGHTNESS 0x040404
38-
#define LED_STATE_ON 1
3941

4042
/*------------------------------------------------------------------*/
4143
/* BUTTON

src/usb/uf2/compile_date.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ SOFTWARE.
4343
: (__DATE__ [2u] == 'y' ) ? 5u /*May*/ \
4444
: (__DATE__ [2u] == 'n' ) ? 6u /*Jun*/ \
4545
: (__DATE__ [2u] == 'l' ) ? 7u /*Jul*/ \
46-
: (__DATE__ [2u] == 'g' ) ? 8u /*Jul*/ \
47-
: (__DATE__ [2u] == 'p' ) ? 9u /*Jul*/ \
48-
: (__DATE__ [2u] == 't' ) ? 10u /*Jul*/ \
49-
: (__DATE__ [2u] == 'v' ) ? 11u /*Jul*/ \
46+
: (__DATE__ [2u] == 'g' ) ? 8u /*Aug*/ \
47+
: (__DATE__ [2u] == 'p' ) ? 9u /*Sep*/ \
48+
: (__DATE__ [2u] == 't' ) ? 10u /*Oct*/ \
49+
: (__DATE__ [2u] == 'v' ) ? 11u /*Nov*/ \
5050
: 12u /*Dec*/ )
5151

5252
#define __DAY_INT__ ( \
@@ -71,12 +71,12 @@ SOFTWARE.
7171
#define __DOSDATE__ ( \
7272
((__YEAR_INT__ - 1980u) << 9u) | \
7373
( __MONTH_INT__ << 5u) | \
74-
( __DAY_INT__ << 0u) )
74+
( __DAY_INT__ << 0u) )
7575

7676
#define __DOSTIME__ ( \
77-
( __HOUR_INT__ << 11u) | \
78-
( __MONTH_INT__ << 5u) | \
79-
( __DAY_INT__ << 0u) )
77+
( __HOUR_INT__ << 11u) | \
78+
( __MINUTE_INT__ << 5u) | \
79+
( __SECONDS_INT__ << 0u) )
8080

8181
#endif // COMPILE_DATE_H
8282

0 commit comments

Comments
 (0)