Compare commits
1 Commits
wip/pico-u
...
pr/nrf5284
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3259f941b4 |
@@ -61,7 +61,11 @@ extern "C" {
|
||||
|
||||
|
||||
/* ------------------------- Interrupt Number Definition ------------------------ */
|
||||
|
||||
/* Note: Interrupt numbers are same as peripheral ID, which can be determined by
|
||||
base address of the peripheral's register block. This applies to
|
||||
peripherals with base address of 0x400xx000, where xx is the id. Be
|
||||
mindful that some peripherals share ids.
|
||||
*/
|
||||
typedef enum {
|
||||
/* ------------------- Cortex-M4 Processor Exceptions Numbers ------------------- */
|
||||
Reset_IRQn = -15, /*!< 1 Reset Vector, invoked on Power up and warm reset */
|
||||
@@ -113,7 +117,12 @@ typedef enum {
|
||||
SPIM2_SPIS2_SPI2_IRQn = 35, /*!< 35 SPIM2_SPIS2_SPI2 */
|
||||
RTC2_IRQn = 36, /*!< 36 RTC2 */
|
||||
I2S_IRQn = 37, /*!< 37 I2S */
|
||||
FPU_IRQn = 38 /*!< 38 FPU */
|
||||
FPU_IRQn = 38, /*!< 38 FPU */
|
||||
USBD_IRQn = 39, /*!< 39 USBD */
|
||||
UARTE1_IRQn = 40, /*!< 40 UARTE1 */
|
||||
QSPI_IRQn = 41, /*!< 41 QSPI */
|
||||
PWM3_IRQn = 45, /*!< 45 PWM3 */
|
||||
SPIM3_IRQn = 47, /*!< 47 SPIM3 */
|
||||
} IRQn_Type;
|
||||
|
||||
|
||||
@@ -1950,6 +1959,29 @@ typedef struct { /*!< GPIO Structure
|
||||
} NRF_GPIO_Type;
|
||||
|
||||
|
||||
/* ================================================================================ */
|
||||
/* ================ USBD ================ */
|
||||
/* ================================================================================ */
|
||||
typedef struct {
|
||||
/* TODO - replace with register descriptors */
|
||||
__IO uint32_t REGS[491];
|
||||
} NRF_USBD_Type;
|
||||
|
||||
|
||||
/* ================================================================================ */
|
||||
/* ================ QSPI ================ */
|
||||
/* ================================================================================ */
|
||||
typedef struct {
|
||||
/* TODO - replace with register descriptors */
|
||||
__IO uint32_t REGS[401];
|
||||
} NRF_QSPI_Type;
|
||||
|
||||
|
||||
/**
|
||||
* @brief GPIO Port 1 (GPIO)
|
||||
*/
|
||||
|
||||
|
||||
/* -------------------- End of section using anonymous unions ------------------- */
|
||||
#if defined(__CC_ARM)
|
||||
#pragma pop
|
||||
@@ -2037,6 +2069,11 @@ typedef struct { /*!< GPIO Structure
|
||||
#define NRF_RTC2_BASE 0x40024000UL
|
||||
#define NRF_I2S_BASE 0x40025000UL
|
||||
#define NRF_FPU_BASE 0x40026000UL
|
||||
#define NRF_USBD_BASE 0x40027000UL
|
||||
#define NRF_UARTE1_BASE 0x40028000UL
|
||||
#define NRF_QSPI_BASE 0x40029000UL
|
||||
#define NRF_PWM3_BASE 0x4002D000UL
|
||||
#define NRF_SPIM3_BASE 0x4002F000UL
|
||||
#define NRF_P0_BASE 0x50000000UL
|
||||
|
||||
|
||||
@@ -2109,6 +2146,11 @@ typedef struct { /*!< GPIO Structure
|
||||
#define NRF_RTC2 ((NRF_RTC_Type *) NRF_RTC2_BASE)
|
||||
#define NRF_I2S ((NRF_I2S_Type *) NRF_I2S_BASE)
|
||||
#define NRF_FPU ((NRF_FPU_Type *) NRF_FPU_BASE)
|
||||
#define NRF_USBD ((NRF_USBD_Type *) NRF_USBD_BASE)
|
||||
#define NRF_UARTE1 ((NRF_UARTE_Type *) NRF_UARTE1_BASE)
|
||||
#define NRF_QSPI ((NRF_QSPI_Type *) NRF_QSPI_BASE)
|
||||
#define NRF_PWM3 ((NRF_PWM_Type *) NRF_PWM3_BASE)
|
||||
#define NRF_SPIM3 ((NRF_SPIM_Type *) NRF_SPIM3_BASE)
|
||||
#define NRF_P0 ((NRF_GPIO_Type *) NRF_P0_BASE)
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <target/debugconfig.h>
|
||||
|
||||
|
||||
|
||||
void nrf52_debug_early_init(void)
|
||||
{
|
||||
uart_init_early();
|
||||
|
||||
@@ -26,6 +26,10 @@ ifeq ($(NRF52_CHIP),nrf52832-chab)
|
||||
GLOBAL_DEFINES +=
|
||||
MEMSIZE ?= 32768
|
||||
endif
|
||||
ifeq ($(NRF52_CHIP),nrf52840-qiaa)
|
||||
GLOBAL_DEFINES +=
|
||||
MEMSIZE ?= 262144
|
||||
endif
|
||||
|
||||
GLOBAL_INCLUDES += $(LOCAL_DIR)
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#define RXBUF_SIZE 16
|
||||
|
||||
//cbuf_t uart0_rx_buf;
|
||||
cbuf_t uart0_rx_buf;
|
||||
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ void uart_init_early(void)
|
||||
UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos;
|
||||
NVIC_DisableIRQ(UARTE0_UART0_IRQn);
|
||||
NRF_UART0->ENABLE = UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos;
|
||||
NRF_UART0->TXD = 'E';
|
||||
NRF_UART0->TASKS_STARTTX=1;
|
||||
NRF_UART0->TASKS_STARTRX=1;
|
||||
#endif //ENABLE_UART0
|
||||
@@ -70,10 +69,10 @@ void uart_init_early(void)
|
||||
void uart_init(void)
|
||||
{
|
||||
#ifdef ENABLE_UART0
|
||||
// cbuf_initialize(&uart0_rx_buf, RXBUF_SIZE);
|
||||
// NRF_UART0->INTENSET = UART_INTENSET_RXDRDY_Enabled << UART_INTENSET_RXDRDY_Pos;
|
||||
cbuf_initialize(&uart0_rx_buf, RXBUF_SIZE);
|
||||
NRF_UART0->INTENSET = UART_INTENSET_RXDRDY_Enabled << UART_INTENSET_RXDRDY_Pos;
|
||||
NRF_UART0->EVENTS_RXDRDY = 0;
|
||||
// NVIC_EnableIRQ(UART0_IRQn);
|
||||
NVIC_EnableIRQ(UARTE0_UART0_IRQn);
|
||||
char c = NRF_UART0->RXD;
|
||||
(void)c;
|
||||
#endif //ENABLE_UART0
|
||||
@@ -81,21 +80,21 @@ void uart_init(void)
|
||||
|
||||
void nrf52_UARTE0_UART0_IRQ(void)
|
||||
{
|
||||
// char c;
|
||||
char c;
|
||||
arm_cm_irq_entry();
|
||||
/*
|
||||
bool resched = false;
|
||||
while ( NRF_UART0->EVENTS_RXDRDY > 0 ) {
|
||||
NRF_UART0->EVENTS_RXDRDY = 0;
|
||||
c = NRF_UART0->RXD;
|
||||
if (!cbuf_space_avail(&uart0_rx_buf)) {
|
||||
break;
|
||||
}
|
||||
cbuf_write_char(&uart0_rx_buf, c, false);
|
||||
resched = true;
|
||||
|
||||
bool resched = false;
|
||||
while ( NRF_UART0->EVENTS_RXDRDY > 0 ) {
|
||||
NRF_UART0->EVENTS_RXDRDY = 0;
|
||||
c = NRF_UART0->RXD;
|
||||
if (!cbuf_space_avail(&uart0_rx_buf)) {
|
||||
break;
|
||||
}
|
||||
*/
|
||||
arm_cm_irq_exit(false);
|
||||
cbuf_write_char(&uart0_rx_buf, c, false);
|
||||
resched = true;
|
||||
}
|
||||
|
||||
arm_cm_irq_exit(resched);
|
||||
}
|
||||
|
||||
int uart_putc(int port, char c)
|
||||
@@ -108,12 +107,12 @@ int uart_putc(int port, char c)
|
||||
|
||||
int uart_getc(int port, bool wait)
|
||||
{
|
||||
do {
|
||||
if (NRF_UART0->EVENTS_RXDRDY > 0) {
|
||||
NRF_UART0->EVENTS_RXDRDY=0;
|
||||
return NRF_UART0->RXD;
|
||||
}
|
||||
} while (wait);
|
||||
cbuf_t *rxbuf = &uart0_rx_buf;
|
||||
|
||||
char c;
|
||||
if (cbuf_read_char(rxbuf, &c, wait) == 1)
|
||||
return c;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
8
project/nrf52-pca10056-test.mk
Normal file
8
project/nrf52-pca10056-test.mk
Normal file
@@ -0,0 +1,8 @@
|
||||
MODULES += \
|
||||
app/shell \
|
||||
app/tests \
|
||||
|
||||
|
||||
|
||||
|
||||
include project/target/nrf-pca10056.mk
|
||||
3
project/target/nrf-pca10056.mk
Normal file
3
project/target/nrf-pca10056.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
LOCAL_DIR := $(GET_LOCAL_DIR)
|
||||
|
||||
TARGET := nrf-pca10056
|
||||
28
target/nrf-pca10056/include/target/debugconfig.h
Normal file
28
target/nrf-pca10056/include/target/debugconfig.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Travis Geiselbrecht
|
||||
*
|
||||
* 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 __TARGET_DEBUGCONFIG_H
|
||||
#define __TARGET_DEBUGCONFIG_H
|
||||
|
||||
#define DEBUG_UART 0
|
||||
|
||||
#endif
|
||||
38
target/nrf-pca10056/include/target/gpioconfig.h
Normal file
38
target/nrf-pca10056/include/target/gpioconfig.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Travis Geiselbrecht
|
||||
*
|
||||
* 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 __TARGET_GPIOCONFIG_H
|
||||
#define __TARGET_GPIOCONFIG_H
|
||||
|
||||
#include <platform/gpio.h>
|
||||
|
||||
#define GPIO_LED1 13
|
||||
#define GPIO_LED2 14
|
||||
#define GPIO_LED3 15
|
||||
#define GPIO_LED4 16
|
||||
|
||||
#define UART0_TX_PIN 6
|
||||
#define UART0_RX_PIN 8
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
52
target/nrf-pca10056/init.c
Normal file
52
target/nrf-pca10056/init.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Travis Geiselbrecht
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#include <err.h>
|
||||
#include <debug.h>
|
||||
#include <target.h>
|
||||
#include <compiler.h>
|
||||
#include <dev/gpio.h>
|
||||
#include <platform/gpio.h>
|
||||
#include <platform/nrf52.h>
|
||||
#include <target/gpioconfig.h>
|
||||
|
||||
void target_early_init(void)
|
||||
{
|
||||
gpio_config(GPIO_LED1, GPIO_OUTPUT);
|
||||
gpio_config(GPIO_LED2, GPIO_OUTPUT);
|
||||
gpio_config(GPIO_LED3, GPIO_OUTPUT);
|
||||
gpio_config(GPIO_LED4, GPIO_OUTPUT);
|
||||
|
||||
gpio_set(GPIO_LED1,0);
|
||||
gpio_set(GPIO_LED2,0);
|
||||
gpio_set(GPIO_LED3,0);
|
||||
gpio_set(GPIO_LED4,0);
|
||||
|
||||
nrf52_debug_early_init();
|
||||
}
|
||||
|
||||
|
||||
void target_init(void)
|
||||
{
|
||||
nrf52_debug_init();
|
||||
dprintf(SPEW,"Target: PCA10056 DK...\n");
|
||||
}
|
||||
17
target/nrf-pca10056/rules.mk
Normal file
17
target/nrf-pca10056/rules.mk
Normal file
@@ -0,0 +1,17 @@
|
||||
LOCAL_DIR := $(GET_LOCAL_DIR)
|
||||
|
||||
MODULE := $(LOCAL_DIR)
|
||||
|
||||
NRF52_CHIP := nrf52840-qiaa
|
||||
|
||||
PLATFORM := nrf52xxx
|
||||
|
||||
GLOBAL_DEFINES += \
|
||||
ENABLE_UART0=1 \
|
||||
|
||||
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/init.c
|
||||
|
||||
include make/module.mk
|
||||
|
||||
Reference in New Issue
Block a user