First code tested on the actual pinetime hardware

This commit is contained in:
JF 2019-12-02 19:42:10 +01:00
parent 2ea27e0cda
commit 66182d15bc
7 changed files with 181 additions and 13 deletions

View file

@ -1,4 +1,4 @@
# nrf52-baseproject
# PineTime
This is a CMake project that configure everything needed to build applications for the NRF52 MCU. It configures the toolchain (arm-none-eabi) and the NRF52 SDK.
The CMake files are taken from https://github.com/Polidea/cmake-nRF5x

View file

@ -208,6 +208,8 @@ macro(nRF5x_setup)
"${NRF5_SDK_PATH}/components/libraries/usbd/class/hid/mouse"
"${NRF5_SDK_PATH}/components/libraries/usbd/class/msc"
"${NRF5_SDK_PATH}/components/libraries/util"
)
# librarires sources
@ -255,6 +257,21 @@ macro(nRF5x_setup)
"${NRF5_SDK_PATH}/external/fprintf/nrf_fprintf_format.c"
)
# LCD/GFX
include_directories(
"${NRF5_SDK_PATH}/external/thedotfactory_fonts"
)
list(APPEND SDK_SOURCE_FILES
"${NRF5_SDK_PATH}/components/libraries/gfx/nrf_gfx.c"
"${NRF5_SDK_PATH}/integration/nrfx/legacy/nrf_drv_spi.c"
# "${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_spi.c"
"${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_spim.c"
"${NRF5_SDK_PATH}/modules/nrfx/drivers/src/prs/nrfx_prs.c"
"${NRF5_SDK_PATH}/components/drivers_ext/st7735/st7735.c"
)
#BLE S132
include_directories(
"${NRF5_SDK_PATH}/components/ble/common"

View file

@ -17,7 +17,9 @@ void BlinkApp::Process(void *instance) {
NRF_LOG_INFO("BlinkApp task started!");
while (1) {
NRF_LOG_INFO("BlinkApp task running!");
bsp_board_led_invert(0);
// nrf_gpio_pin_toggle(22);
// nrf_gpio_pin_toggle(23);
// nrf_gpio_pin_toggle(14);
vTaskDelay(1000);
}
}

5
src/drivers/st7789.cpp Normal file
View file

@ -0,0 +1,5 @@
//
// Created by jf on 12/2/19.
//
#include "st7789.h"

14
src/drivers/st7789.h Normal file
View file

@ -0,0 +1,14 @@
//
// Created by jf on 12/2/19.
//
#ifndef PINETIME_ST7789_H
#define PINETIME_ST7789_H
class st7789 {
};
#endif //PINETIME_ST7789_H

View file

@ -7,6 +7,8 @@
#include <legacy/nrf_drv_clock.h>
#include <libraries/timer/app_timer.h>
#include <libraries/gpiote/app_gpiote.h>
#include <libraries/gfx/nrf_lcd.h>
#include "nrf_gfx.h"
#if NRF_LOG_ENABLED
@ -43,6 +45,25 @@ static void bsp_event_handler(bsp_event_t event)
}
}
extern const nrf_lcd_t nrf_lcd_st7735;
static nrf_lcd_t const * p_lcd = &nrf_lcd_st7735;
static void gfx_initialization(void)
{
nrf_gpio_cfg_output(14);
nrf_gpio_cfg_output(22);
nrf_gpio_cfg_output(23);
nrf_gpio_pin_clear(14);
nrf_gpio_pin_set(22);
nrf_gpio_pin_set(23);
APP_ERROR_CHECK(nrf_gfx_init(p_lcd));
nrf_gfx_rect_t rect;
rect.height = 10;
rect.width = 10;
rect.x = 10;
rect.y = 10;
nrf_gfx_rect_draw(p_lcd, &rect, 2, 0xffffffff, true);
}
void SystemTask(void *) {
APP_GPIOTE_INIT(2);
@ -51,6 +72,9 @@ void SystemTask(void *) {
bsp_board_init(BSP_INIT_LEDS|BSP_INIT_BUTTONS);
bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_event_handler);
gfx_initialization();
blinkApp.Start();
while (1) {
@ -58,6 +82,8 @@ void SystemTask(void *) {
}
}
int main(void) {
logger.Init();
nrf_drv_clock_init();

View file

@ -4384,13 +4384,13 @@
// <e> NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver
//==========================================================
#ifndef NRFX_SPIM_ENABLED
#define NRFX_SPIM_ENABLED 0
#define NRFX_SPIM_ENABLED 1
#endif
// <q> NRFX_SPIM0_ENABLED - Enable SPIM0 instance
#ifndef NRFX_SPIM0_ENABLED
#define NRFX_SPIM0_ENABLED 0
#define NRFX_SPIM0_ENABLED 1
#endif
// <q> NRFX_SPIM1_ENABLED - Enable SPIM1 instance
@ -4435,7 +4435,7 @@
// <e> NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module.
//==========================================================
#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED
#define NRFX_SPIM_CONFIG_LOG_ENABLED 0
#define NRFX_SPIM_CONFIG_LOG_ENABLED 1
#endif
// <o> NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level
@ -4575,7 +4575,7 @@
// <0=> Default
// <1=> Black
// <2=> Red
// <2=> Red <
// <3=> Green
// <4=> Yellow
// <5=> Blue
@ -6456,7 +6456,7 @@
// <e> SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer
//==========================================================
#ifndef SPI_ENABLED
#define SPI_ENABLED 0
#define SPI_ENABLED 1
#endif
// <o> SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority
@ -6488,7 +6488,7 @@
// <e> SPI0_ENABLED - Enable SPI0 instance
//==========================================================
#ifndef SPI0_ENABLED
#define SPI0_ENABLED 0
#define SPI0_ENABLED 1
#endif
// <q> SPI0_USE_EASY_DMA - Use EasyDMA
@ -8142,7 +8142,11 @@
#ifndef NRF_GFX_ENABLED
#define NRF_GFX_ENABLED 0
#define NRF_GFX_ENABLED 1
#endif
#ifndef ST7735_ENABLED
#define ST7735_ENABLED 1
#endif
// <q> NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module
@ -9617,7 +9621,7 @@
// <e> SPI_CONFIG_LOG_ENABLED - Enables logging in the module.
//==========================================================
#ifndef SPI_CONFIG_LOG_ENABLED
#define SPI_CONFIG_LOG_ENABLED 0
#define SPI_CONFIG_LOG_ENABLED 1
#endif
// <o> SPI_CONFIG_LOG_LEVEL - Default Severity level
@ -12933,6 +12937,106 @@
#endif
// <<< end of configuration section >>>
#endif //SDK_CONFIG_H
// <o> ST7735_SCK_PIN - Pin number <0-47>
#ifndef ST7735_SCK_PIN
#define ST7735_SCK_PIN 2
#endif
// <o> ST7735_MISO_PIN - Pin number <0-47>
#ifndef ST7735_MISO_PIN
#define ST7735_MISO_PIN 4
#endif
// <o> ST7735_MOSI_PIN - Pin number <0-47>
#ifndef ST7735_MOSI_PIN
#define ST7735_MOSI_PIN 3
#endif
// <o> ST7735_SS_PIN - Pin number <0-47>
#ifndef ST7735_SS_PIN
#define ST7735_SS_PIN 25
#endif
// <o> ST7735_IRQ_PRIORITY - Interrupt priority
// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// <0=> 0 (highest)
// <1=> 1
// <2=> 2
// <3=> 3
// <4=> 4
// <5=> 5
// <6=> 6
// <7=> 7
#ifndef ST7735_IRQ_PRIORITY
#define ST7735_IRQ_PRIORITY 3
#endif
// </h>
//==========================================================
// <o> ST7735_SPI_INSTANCE
// <0=> 0
// <1=> 1
// <2=> 2
#ifndef ST7735_SPI_INSTANCE
#define ST7735_SPI_INSTANCE 0
#endif
#ifndef ST7735_SPI_MODE
#define ST7735_SPI_MODE 3
#endif
#ifndef ST7735_SPI_FREQUENCY
#define ST7735_SPI_FREQUENCY 8000000
#endif
// <o> ST7735_TAB_COLOR - Color of the tab attached to the screen.
// <0=> INITR_GREENTAB
// <1=> INITR_REDTAB
// <2=> INITR_BLACKTAB
// <3=> INITR_144GREENTAB
#ifndef ST7735_TAB_COLOR
#define ST7735_TAB_COLOR 2
#endif
// <o> ST7735_DC_PIN - Pin number <0-47>
#ifndef ST7735_DC_PIN
#define ST7735_DC_PIN 18
#endif
// <o> ST7735_HEIGHT - ST7735 height <0-162>
#ifndef ST7735_HEIGHT
#define ST7735_HEIGHT 160
#endif
// <o> ST7735_WIDTH - ST7735 width <0-132>
#ifndef ST7735_WIDTH
#define ST7735_WIDTH 128
#endif
// <<< end of configuration section >>>
#endif //SDK_CONFIG_H