Skip to content

Commit 8db6efe

Browse files
committed
Initial commit
0 parents  commit 8db6efe

File tree

11 files changed

+718
-0
lines changed

11 files changed

+718
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.bak
2+
*~

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# ArduinoHwNRF5
2+
3+
Arduino hardware definitions for Mysensors nRF5 boards
4+
5+
## MyNRF5Board
6+
7+
This repository allows managing the nRF5 pin mapping as part of your code.
8+
You can use the method for any nRF51822 or nRF52832 board or module.
9+
10+
Most components, like UART, SPI, Wire Bus, of the nRF5 series chips don't
11+
have a fixed pin mapping. There are some pins with restrictions like analog
12+
inputs, NFC or pins near the radio module. Please refer the latest
13+
documentation about pin restrictions at http://infocenter.nordicsemi.com
14+
15+
To use the custom pin mapping you have to do following steps:
16+
17+
1. Install "arduino-nrf5" like described at
18+
https://github.com/sandeepmistry/arduino-nRF5/
19+
2. Install the "My Sensors nRF5 Boards" with the board manager like
20+
explained at https://github.com/mysensors/ArduinoBoards
21+
3. Copy the files "MyNRF5Board.cpp" and "MyNRF5Board.h" from
22+
"MyNRF5Board" example into your sketch.
23+
4. Modify pin mappings in "MyNRF5Board.cpp" and "MyNRF5Board.h" to fit
24+
your requirements.
25+
5. Select "MyNRF5Board nrf52832" or "MyNRF5Board nrf52822" as your board.
26+
Choose the correct parameters and programmer in the Tools menu.
27+
28+
### MyNRF5Board.h
29+
30+
This file allows you to change the pins of internal hardware, like the
31+
serial port, SPI bus or Wire bus.
32+
33+
All pins referenced here are mapped via the "g_ADigitalPinMap" Array
34+
defined in "MyNRF5Board.cpp" to pins of the MCU.
35+
36+
As an example, if you have at the third position in "g_ADigitalPinMap" the
37+
12, then all ports referenced in Arduino with 2 are mapped to P0.12. If you
38+
don't change the "g_ADigitalPinMap" Array, the Arduino pins 0..31 are
39+
translated to P0.00..P0..31.
40+
41+
### MyNRF5Board.cpp
42+
43+
This file allows you to change the relation between pins referenced in
44+
the Arduino IDE (0..31) and pins of the nRF5 MCU (P0.00..P0.31).
45+
46+
If you can live with addressing the GPIO pins by using the Arduino pins
47+
0..31 instead of a custom mapping, don't change this file. If you have
48+
a lot of Arduino code with fixed pin numbers and you need to map these
49+
pins to specific pins of the nRF5 MCU; you need to change this file.
50+
51+
If you fill the "g_ADigitalPinMap" Array with numbers between 0..31,
52+
the Arduino pins 0..31 are assigned to pins P0.00..P0.31 of the MCU.
53+
54+
As an example, if you need to change the pin mapping for Arduino pin 5
55+
to P0.12 of the MCU, you have to write the 12 into the sixth position
56+
in the "g_ADigitalPinMap" Array.
57+
58+
The pin mapping effects commands like "pinMode()", "digitalWrite()",
59+
"analogRead()" and "analogWrite()".
60+
61+
If you change the pin mapping, you have to modify the pins in
62+
"MyNRF5Board.h". Especially the analog pin mapping must be replaced with
63+
your pin numbers by replacing PIN_AIN0..7 with a number of your mapping
64+
array. You can use the constants PIN_AIN0..7 in the "g_ADigitalPinMap"
65+
Array if you want to reference analog ports MCU independent. You cannot
66+
use the pins P0.00 and P0.01 for GPIO, when the 32kHz crystal is connected.

boards.txt

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
2+
# Copyright (c) 2016 Sandeep Mistry All right reserved.
3+
# Copyright (c) 2017 Frank Holtz All right reserved.
4+
#
5+
# This library is free software; you can redistribute it and/or
6+
# modify it under the terms of the GNU Lesser General Public
7+
# License as published by the Free Software Foundation; either
8+
# version 2.1 of the License, or (at your option) any later version.
9+
#
10+
# This library is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+
# See the GNU Lesser General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU Lesser General Public
16+
# License along with this library; if not, write to the Free Software
17+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
19+
menu.chip=Chip
20+
menu.bootcode=Bootloader/SD
21+
menu.lfclk=Low Frequency Clock
22+
menu.reset=Reset
23+
24+
# MyNRF5Board nRF52832
25+
# Board definition is expected in
26+
# MyBoard.cpp and MyBoard.h as part
27+
# of the sketch
28+
###################################
29+
30+
MyBoard_nRF52832.name=MyNRF5Board nRF52832
31+
32+
MyBoard_nRF52832.bootloader.tool=sandeepmistry:openocd
33+
34+
MyBoard_nRF52832.upload.tool=sandeepmistry:openocd
35+
MyBoard_nRF52832.upload.target=nrf52
36+
MyBoard_nRF52832.upload.maximum_size=524288
37+
38+
MyBoard_nRF52832.build.mcu=cortex-m4
39+
MyBoard_nRF52832.build.f_cpu=16000000
40+
MyBoard_nRF52832.build.board=GENERIC
41+
MyBoard_nRF52832.build.core=sandeepmistry:nRF5
42+
MyBoard_nRF52832.build.variant=MyNRF5Board
43+
MyBoard_nRF52832.build.variant_system_lib=
44+
# -I{build.path} and -DMYNRF5BOARD is only required by MyNRF5Board
45+
MyBoard_nRF52832.build.extra_flags=-DNRF52 -DMYNRF5BOARD -I{build.path}
46+
MyBoard_nRF52832.build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16
47+
MyBoard_nRF52832.build.ldscript=nrf52_xxaa.ld
48+
49+
MyBoard_nRF52832.menu.bootcode.none=None
50+
MyBoard_nRF52832.menu.bootcode.none.softdevice=none
51+
MyBoard_nRF52832.menu.bootcode.s132=S132 (SoftDevice)
52+
MyBoard_nRF52832.menu.bootcode.s132.softdevice=s132
53+
MyBoard_nRF52832.menu.bootcode.s132.softdeviceversion=2.0.1
54+
MyBoard_nRF52832.menu.bootcode.s132.upload.maximum_size=409600
55+
MyBoard_nRF52832.menu.bootcode.s132.build.extra_flags=-DNRF52 -DS132 -DNRF51_S132 -DSOFTDEVICE_PRESENT
56+
MyBoard_nRF52832.menu.bootcode.s132.build.ldscript=armgcc_s132_nrf52832_xxaa.ld
57+
58+
MyBoard_nRF52832.menu.lfclk.lfxo=Crystal Oscillator
59+
MyBoard_nRF52832.menu.lfclk.lfxo.build.lfclk_flags=-DUSE_LFXO
60+
MyBoard_nRF52832.menu.lfclk.lfrc=RC Oscillator
61+
MyBoard_nRF52832.menu.lfclk.lfrc.build.lfclk_flags=-DUSE_LFRC
62+
MyBoard_nRF52832.menu.lfclk.lfsynt=Synthesized
63+
MyBoard_nRF52832.menu.lfclk.lfsynt.build.lfclk_flags=-DUSE_LFSYNT
64+
65+
MyBoard_nRF52832.menu.reset.notenable=Don't enable
66+
MyBoard_nRF52832.menu.reset.enabled=Enable
67+
MyBoard_nRF52832.menu.reset.enabled.build.reset_flags=-DCONFIG_GPIO_AS_PINRESET
68+
69+
70+
# MyNRF5Board nRF51822
71+
# Board definition is expected in
72+
# MyBoard.cpp and MyBoard.h as part
73+
# of the sketch
74+
###################################
75+
76+
MyBoard_nRF51822.name=MyNRF5Board nRF51822
77+
MyBoard_nRF51822.bootloader.tool=sandeepmistry:openocd
78+
MyBoard_nRF51822.upload.tool=sandeepmistry:openocd
79+
MyBoard_nRF51822.upload.target=nrf51
80+
MyBoard_nRF51822.upload.maximum_size=262144
81+
82+
MyBoard_nRF51822.build.mcu=cortex-m0
83+
MyBoard_nRF51822.build.f_cpu=16000000
84+
MyBoard_nRF51822.build.board=GENERIC
85+
MyBoard_nRF51822.build.core=sandeepmistry:nRF5
86+
MyBoard_nRF51822.build.variant=MyNRF5Board
87+
MyBoard_nRF51822.build.variant_system_lib=
88+
# -I{build.path} and -DMYNRF5BOARD is only required by MyNRF5Board
89+
MyBoard_nRF51822.build.extra_flags=-DNRF51 -DMYNRF5BOARD -I{build.path}
90+
MyBoard_nRF51822.build.float_flags=
91+
MyBoard_nRF51822.build.ldscript=nrf51_{build.chip}.ld
92+
93+
MyBoard_nRF51822.menu.chip.xxaa=16 kB RAM, 256 kB flash (xxaa)
94+
MyBoard_nRF51822.menu.chip.xxaa.build.chip=xxaa
95+
MyBoard_nRF51822.menu.chip.xxac=32 kB RAM, 256 kB flash (xxac)
96+
MyBoard_nRF51822.menu.chip.xxac.build.chip=xxac
97+
98+
MyBoard_nRF51822.menu.bootcode.none=None
99+
MyBoard_nRF51822.menu.bootcode.none.softdevice=none
100+
MyBoard_nRF51822.menu.bootcode.s110=S110 (SoftDevice)
101+
MyBoard_nRF51822.menu.bootcode.s110.softdevice=s110
102+
MyBoard_nRF51822.menu.bootcode.s110.softdeviceversion=8.0.0
103+
MyBoard_nRF51822.menu.bootcode.s110.upload.maximum_size=151552
104+
MyBoard_nRF51822.menu.bootcode.s110.build.extra_flags=-DNRF51 -DS110 -DNRF51_S110 -DSOFTDEVICE_PRESENT
105+
MyBoard_nRF51822.menu.bootcode.s110.build.ldscript=armgcc_s110_nrf51822_{build.chip}.ld
106+
MyBoard_nRF51822.menu.bootcode.s130=S130 (SoftDevice)
107+
MyBoard_nRF51822.menu.bootcode.s130.softdevice=s130
108+
MyBoard_nRF51822.menu.bootcode.s130.softdeviceversion=2.0.1
109+
MyBoard_nRF51822.menu.bootcode.s130.upload.maximum_size=151552
110+
MyBoard_nRF51822.menu.bootcode.s130.build.extra_flags=-DNRF51 -DS130 -DNRF51_S130 -DSOFTDEVICE_PRESENT
111+
MyBoard_nRF51822.menu.bootcode.s130.build.ldscript=armgcc_s130_nrf51822_{build.chip}.ld
112+
113+
MyBoard_nRF51822.menu.lfclk.lfxo=Crystal Oscillator
114+
MyBoard_nRF51822.menu.lfclk.lfxo.build.lfclk_flags=-DUSE_LFXO
115+
MyBoard_nRF51822.menu.lfclk.lfrc=RC Oscillator
116+
MyBoard_nRF51822.menu.lfclk.lfrc.build.lfclk_flags=-DUSE_LFRC
117+
MyBoard_nRF51822.menu.lfclk.lfsynt=Synthesized
118+
MyBoard_nRF51822.menu.lfclk.lfsynt.build.lfclk_flags=-DUSE_LFSYNT

libraries/MyNRF5Board/dummy.h

Whitespace-only changes.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
If you don't use an nRF5 board, you can ignore this file.
3+
4+
This file was part of the "My Sensors nRF5 Boards" board repository
5+
available at https://github.com/mysensors/ArduinoBoards If you have
6+
questions, please refer the documentation at
7+
https://github.com/mysensors/ArduinoHwNRF5 first.
8+
9+
This file is compatible with ArduinoHwNRF5 > 0.1.0
10+
11+
This file allows you to change the relation between pins referenced in
12+
the Arduino IDE (0..31) and pins of the nRF5 MCU (P0.00..P0.31).
13+
14+
If you can live with addressing the GPIO pins by using the Arduino pins
15+
0..31 instead of a custom mapping, don't change this file. If you have
16+
a lot of Arduino code with fixed pin numbers and you need to map these
17+
pins to specific pins of the nRF5 MCU; you need to change this file.
18+
19+
If you fill the "g_ADigitalPinMap" Array with numbers between 0..31,
20+
the Arduino pins 0..31 are assigned to pins P0.00..P0.31 of the MCU.
21+
22+
As an example, if you need to change the pin mapping for Arduino pin 5
23+
to P0.12 of the MCU, you have to write the 12 into the sixth position
24+
in the "g_ADigitalPinMap" Array.
25+
26+
The pin mapping effects commands like "pinMode()", "digitalWrite()",
27+
"analogRead()" and "analogWrite()".
28+
29+
If you change the pin mapping, you have to modify the pins in
30+
"MyNRF5Board.h". Especially the analog pin mapping must be replaced with
31+
your pin numbers by replacing PIN_AIN0..7 with a number of your mapping
32+
array. You can use the constants PIN_AIN0..7 in the "g_ADigitalPinMap"
33+
Array if you want to reference analog ports MCU independent. You cannot
34+
use the pins P0.00 and P0.01 for GPIO, when the 32kHz crystal is connected.
35+
36+
37+
###########################################################################
38+
39+
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
40+
Copyright (c) 2016 Sandeep Mistry. All right reserved.
41+
Copyright (c) 2017 Sensnology AB. All right reserved.
42+
43+
This library is free software; you can redistribute it and/or
44+
modify it under the terms of the GNU Lesser General Public
45+
License as published by the Free Software Foundation; either
46+
version 2.1 of the License, or (at your option) any later version.
47+
48+
This library is distributed in the hope that it will be useful,
49+
but WITHOUT ANY WARRANTY; without even the implied warranty of
50+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51+
See the GNU Lesser General Public License for more details.
52+
53+
You should have received a copy of the GNU Lesser General Public
54+
License along with this library; if not, write to the Free Software
55+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
56+
*/
57+
58+
59+
60+
#ifdef MYNRF5BOARD
61+
#include <variant.h>
62+
63+
const uint32_t g_ADigitalPinMap[] = {
64+
0,
65+
1,
66+
2,
67+
3,
68+
4,
69+
5,
70+
6,
71+
7,
72+
8,
73+
9,
74+
10,
75+
11,
76+
12,
77+
13,
78+
14,
79+
15,
80+
16,
81+
17,
82+
18,
83+
19,
84+
20,
85+
21,
86+
22,
87+
23,
88+
24,
89+
25,
90+
26,
91+
27,
92+
28,
93+
29,
94+
30,
95+
31
96+
};
97+
#endif

0 commit comments

Comments
 (0)