From 2779fe9af67bf5bbc9349c7251a0fc2521d38cfd Mon Sep 17 00:00:00 2001 From: rbaron Date: Mon, 14 Nov 2022 08:47:14 +0100 Subject: [PATCH] Started adding a b-parasite board. Not working yet --- code/nrf-connect/CMakeLists.txt | 5 +- .../boards/arm/parasite/Kconfig.board | 4 + .../boards/arm/parasite/Kconfig.defconfig | 7 + .../boards/arm/parasite/parasite.dts | 151 ++++++++++++++++++ .../boards/arm/parasite/parasite_defconfig | 29 ++++ 5 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 code/nrf-connect/boards/arm/parasite/Kconfig.board create mode 100644 code/nrf-connect/boards/arm/parasite/Kconfig.defconfig create mode 100644 code/nrf-connect/boards/arm/parasite/parasite.dts create mode 100644 code/nrf-connect/boards/arm/parasite/parasite_defconfig diff --git a/code/nrf-connect/CMakeLists.txt b/code/nrf-connect/CMakeLists.txt index bd6089b..e4f3269 100644 --- a/code/nrf-connect/CMakeLists.txt +++ b/code/nrf-connect/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(hello_world) + +project(b_parasite) + +# set(BOARD_ROOT .) target_sources(app PRIVATE src/main.c src/prst/shtc3.c src/prst/adc.c) diff --git a/code/nrf-connect/boards/arm/parasite/Kconfig.board b/code/nrf-connect/boards/arm/parasite/Kconfig.board new file mode 100644 index 0000000..afa3bff --- /dev/null +++ b/code/nrf-connect/boards/arm/parasite/Kconfig.board @@ -0,0 +1,4 @@ + +config BOARD_B_PARASITE + bool "b-parasite board" + depends on SOC_NRF52840_QIAA \ No newline at end of file diff --git a/code/nrf-connect/boards/arm/parasite/Kconfig.defconfig b/code/nrf-connect/boards/arm/parasite/Kconfig.defconfig new file mode 100644 index 0000000..b06f3ed --- /dev/null +++ b/code/nrf-connect/boards/arm/parasite/Kconfig.defconfig @@ -0,0 +1,7 @@ + +if BOARD_PARASITE + +config BOARD + default "parasite" + +endif # BOARD_PARASITE \ No newline at end of file diff --git a/code/nrf-connect/boards/arm/parasite/parasite.dts b/code/nrf-connect/boards/arm/parasite/parasite.dts new file mode 100644 index 0000000..2f555f8 --- /dev/null +++ b/code/nrf-connect/boards/arm/parasite/parasite.dts @@ -0,0 +1,151 @@ +/dts-v1/; +#include + +&pinctrl { + /* Configure pwm0 instance to use pin 5. */ + pwm0_default: pwm0_default { + group1 { + psels = ; + nordic,invert; + }; + }; + + pwm0_sleep: pwm0_sleep { + group1 { + psels = ; + low-power-enable; + }; + }; + + /* Configure i2c0 instance to use pins 24 (SDA) & 13 (SCL). */ + i2c0_default: i2c0_default { + group1 { + psels = , + ; + }; + }; + + i2c0_sleep: i2c0_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +&i2c0 { + compatible = "nordic,nrf-twi"; + status = "okay"; + pinctrl-0 = <&i2c0_default>; + pinctrl-1 = <&i2c0_sleep>; + pinctrl-names = "default", "sleep"; + + shtc3: shtc3@70 { + compatible = "i2c-device"; + reg = <0x70>; + label = "SHTC3"; + }; +}; + +&pwm0 { + status = "okay"; + pinctrl-0 = <&pwm0_default>; + pinctrl-1 = <&pwm0_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&adc { + #address-cells = <1>; + #size-cells = <0>; + status = "ok"; + channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1_6"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + // P0.03. + zephyr,input-positive = ; + zephyr,resolution = <10>; + + }; + + channel@1 { + reg = <1>; + zephyr,gain = "ADC_GAIN_1_6"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + // P0.02. + zephyr,input-positive = ; + zephyr,resolution = <10>; + }; + + channel@2 { + reg = <2>; + zephyr,gain = "ADC_GAIN_1_6"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; + zephyr,resolution = <10>; + }; +}; + + +&flash0 { + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 0x0000C000>; + }; + slot0_partition: partition@c000 { + label = "image-0"; + reg = <0x0000C000 0x00067000>; + }; + slot1_partition: partition@73000 { + label = "image-1"; + reg = <0x00073000 0x00067000>; + }; + scratch_partition: partition@da000 { + label = "image-scratch"; + reg = <0x000da000 0x0001e000>; + }; + + /* + * The flash starting at 0x000f8000 and ending at + * 0x000fffff is reserved for use by the application. + */ + + /* + * Storage partition will be used by FCB/LittleFS/NVS + * if enabled. + */ + storage_partition: partition@f8000 { + label = "storage"; + reg = <0x000f8000 0x00008000>; + }; + }; +}; + +/ { + + model = "A soil moisture sensor"; + compatible = "rbaron,b-parasite"; + + zephyr,user { + io-channels = <&adc 0>, <&adc 1>, <&adc 2>; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_partition; + }; + + soil_pwm: soil_pwm { + compatible = "pwm-fixed"; + pwms = <&pwm0 0 PWM_MSEC(100) PWM_POLARITY_INVERTED>; + pulse = ; + }; +}; \ No newline at end of file diff --git a/code/nrf-connect/boards/arm/parasite/parasite_defconfig b/code/nrf-connect/boards/arm/parasite/parasite_defconfig new file mode 100644 index 0000000..4f5d366 --- /dev/null +++ b/code/nrf-connect/boards/arm/parasite/parasite_defconfig @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_SOC_SERIES_NRF52X=y +CONFIG_SOC_NRF52840_QIAA=y +# CONFIG_BOARD_NRF52840DK_NRF52840=y + +# # Enable MPU +CONFIG_ARM_MPU=y + +# # Enable hardware stack protection +CONFIG_HW_STACK_PROTECTION=y + +# # Enable RTT +CONFIG_USE_SEGGER_RTT=y + +# # enable GPIO +CONFIG_GPIO=y + +# # enable uart driver +CONFIG_SERIAL=y + +# # enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# # additional board options +CONFIG_GPIO_AS_PINRESET=y + +CONFIG_PINCTRL=y