Merge branch 'master' into develop

This commit is contained in:
hathach 2019-08-22 21:46:34 +07:00
commit c3fc0dba91
7 changed files with 122 additions and 36 deletions

View File

@ -76,7 +76,7 @@ For other boards, please check the board definition for details.
### Making your own UF2
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.
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
To create a UF2 image from a .bin file:
```

View File

@ -34,7 +34,9 @@
#define SCHED_QUEUE_SIZE 30 /**< Maximum number of events in the scheduler queue. */
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
void neopixel_init(void);
void neopixel_write(uint8_t *pixels);
void neopixel_teardown(void);
#endif
//------------- IMPLEMENTATION -------------//
@ -67,9 +69,8 @@ void board_init(void)
led_pwm_init(LED_SECONDARY, LED_SECONDARY_PIN);
#endif
// use neopixel for use enumeration
// use neopixel for use enumeration
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
extern void neopixel_init(void);
neopixel_init();
#endif
@ -93,7 +94,6 @@ void board_teardown(void)
led_pwm_teardown();
#if defined(LED_NEOPIXEL) || defined(LED_RGB_RED_PIN)
extern void neopixel_teardown(void);
neopixel_teardown();
#endif
// Button
@ -297,9 +297,9 @@ void led_state(uint32_t state)
#define MAGIC_T1H 13UL | (0x8000) // 0.8125us
#define CTOPVAL 20UL // 1.25us
#define NEO_NUMBYTE 3
#define BYTE_PER_PIXEL 3
static uint16_t pixels_pattern[NEO_NUMBYTE * 8 + 2];
static uint16_t pixels_pattern[NEOPIXELS_NUMBER*BYTE_PER_PIXEL * 8 + 2];
// use PWM1 for neopixel
void neopixel_init(void)
@ -347,29 +347,35 @@ void neopixel_init(void)
void neopixel_teardown(void)
{
uint8_t grb[3] = { 0, 0, 0 };
uint8_t rgb[3] = { 0, 0, 0 };
NRFX_DELAY_US(50); // wait for previous write is complete
neopixel_write(grb);
neopixel_write(rgb);
NRFX_DELAY_US(50); // wait for this write
pwm_teardown(NRF_PWM1);
}
// write 3 bytes color to a built-in neopixel
// write 3 bytes color RGB to built-in neopixel
void neopixel_write (uint8_t *pixels)
{
uint8_t grb[NEO_NUMBYTE] = {pixels[1], pixels[2], pixels[0]};
// convert RGB to GRB
uint8_t grb[BYTE_PER_PIXEL] = {pixels[1], pixels[2], pixels[0]};
uint16_t pos = 0; // bit position
for ( uint16_t n = 0; n < NEO_NUMBYTE; n++ )
{
uint8_t pix = grb[n];
for ( uint8_t mask = 0x80; mask > 0; mask >>= 1 )
// Set all neopixel to same value
for (uint16_t n = 0; n < NEOPIXELS_NUMBER; n++ )
{
for(uint8_t c = 0; c < BYTE_PER_PIXEL; c++)
{
pixels_pattern[pos] = (pix & mask) ? MAGIC_T1H : MAGIC_T0H;
pos++;
uint8_t const pix = grb[c];
for ( uint8_t mask = 0x80; mask > 0; mask >>= 1 )
{
pixels_pattern[pos] = (pix & mask) ? MAGIC_T1H : MAGIC_T0H;
pos++;
}
}
}
@ -409,8 +415,8 @@ void neopixel_init(void)
void neopixel_teardown(void)
{
uint8_t grb[3] = { 0, 0, 0 };
neopixel_write(grb);
uint8_t rgb[3] = { 0, 0, 0 };
neopixel_write(rgb);
nrf_gpio_cfg_default(LED_RGB_RED_PIN);
nrf_gpio_cfg_default(LED_RGB_GREEN_PIN);
nrf_gpio_cfg_default(LED_RGB_BLUE_PIN);

View File

@ -32,23 +32,24 @@
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(1, 14)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 13)
#define NEOPIXELS_NUMBER 10
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_STATE_ON 1
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(1, 01) // left button
#define BUTTON_1 _PINNUM(1, 02) // left button
#define BUTTON_2 _PINNUM(1, 15) // right button
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTON_PULL NRF_GPIO_PIN_PULLDOWN
/*------------------------------------------------------------------*/
/* UART
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER _PINNUM(0, 29)
#define RX_PIN_NUMBER _PINNUM(0, 30)
#define TX_PIN_NUMBER _PINNUM(0, 14)
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
@ -68,7 +69,7 @@
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Adafruit Circuit Playground nRF52840"
#define UF2_VOLUME_LABEL "CPLAYBTBOOT"
#define UF2_BOARD_ID "CircuitPlayground-nRF52840-revD"
#define UF2_BOARD_ID "nRF52840-CircuitPlayground-revD"
#define UF2_INDEX_URL "https://www.adafruit.com/product/4300"
#endif // _FEATHER_NRF52840_H
#endif // _CPLAY_NRF52840_H

View File

@ -33,10 +33,12 @@
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN _PINNUM(1, 15)
#define LED_SECONDARY_PIN _PINNUM(1, 10)
#define LED_NEOPIXEL 16
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 16)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/

View File

@ -0,0 +1,75 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Ha Thach for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _ITSYBITSY_NRF52840_H
#define _ITSYBITSY_NRF52840_H
#define _PINNUM(port, pin) ((port)*32 + (pin))
/*------------------------------------------------------------------*/
/* LED
*------------------------------------------------------------------*/
#define LEDS_NUMBER 1
#define LED_PRIMARY_PIN _PINNUM(0, 6)
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 8)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/
#define BUTTONS_NUMBER 2
#define BUTTON_1 _PINNUM(0, 29) // user switch
#define BUTTON_2 _PINNUM(1, 02) // D2 breakout
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
/*------------------------------------------------------------------*/
/* UART
*------------------------------------------------------------------*/
#define RX_PIN_NUMBER _PINNUM(0, 25)
#define TX_PIN_NUMBER _PINNUM(0, 24)
#define CTS_PIN_NUMBER 0
#define RTS_PIN_NUMBER 0
#define HWFC false
// Used as model string in OTA mode
#define BLEDIS_MANUFACTURER "Adafruit Industries"
#define BLEDIS_MODEL "ItsyBitsy nRF52840 Express"
//--------------------------------------------------------------------+
// USB
//--------------------------------------------------------------------+
#define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x0051
#define USB_DESC_CDC_ONLY_PID 0x0052
//------------- UF2 -------------//
#define UF2_PRODUCT_NAME "Adafruit ItsyBitsy nRF52840 Express"
#define UF2_VOLUME_LABEL "ITSY840BOOT"
#define UF2_BOARD_ID "nRF52840-ItsyBitsy-revA"
#define UF2_INDEX_URL "https://www.adafruit.com/"
#endif // _ITSY_NRF52840_H

View File

@ -33,10 +33,12 @@
#define LEDS_NUMBER 2
#define LED_PRIMARY_PIN _PINNUM(1, 13)
#define LED_SECONDARY_PIN _PINNUM(1, 15)
#define LED_NEOPIXEL _PINNUM(0, 13)
#define BOARD_RGB_BRIGHTNESS 0x040404
#define LED_STATE_ON 1
#define LED_NEOPIXEL _PINNUM(0, 13)
#define NEOPIXELS_NUMBER 1
#define BOARD_RGB_BRIGHTNESS 0x040404
/*------------------------------------------------------------------*/
/* BUTTON
*------------------------------------------------------------------*/

View File

@ -43,10 +43,10 @@ SOFTWARE.
: (__DATE__ [2u] == 'y' ) ? 5u /*May*/ \
: (__DATE__ [2u] == 'n' ) ? 6u /*Jun*/ \
: (__DATE__ [2u] == 'l' ) ? 7u /*Jul*/ \
: (__DATE__ [2u] == 'g' ) ? 8u /*Jul*/ \
: (__DATE__ [2u] == 'p' ) ? 9u /*Jul*/ \
: (__DATE__ [2u] == 't' ) ? 10u /*Jul*/ \
: (__DATE__ [2u] == 'v' ) ? 11u /*Jul*/ \
: (__DATE__ [2u] == 'g' ) ? 8u /*Aug*/ \
: (__DATE__ [2u] == 'p' ) ? 9u /*Sep*/ \
: (__DATE__ [2u] == 't' ) ? 10u /*Oct*/ \
: (__DATE__ [2u] == 'v' ) ? 11u /*Nov*/ \
: 12u /*Dec*/ )
#define __DAY_INT__ ( \
@ -71,12 +71,12 @@ SOFTWARE.
#define __DOSDATE__ ( \
((__YEAR_INT__ - 1980u) << 9u) | \
( __MONTH_INT__ << 5u) | \
( __DAY_INT__ << 0u) )
( __DAY_INT__ << 0u) )
#define __DOSTIME__ ( \
( __HOUR_INT__ << 11u) | \
( __MONTH_INT__ << 5u) | \
( __DAY_INT__ << 0u) )
( __HOUR_INT__ << 11u) | \
( __MINUTE_INT__ << 5u) | \
( __SECONDS_INT__ << 0u) )
#endif // COMPILE_DATE_H