Skip to content

Commit ce16377

Browse files
committed
restructured
1 parent 1167c4b commit ce16377

File tree

152 files changed

+66149
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+66149
-0
lines changed

code/bluey-MeArm/README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
## Controlling a MeArm using Bluey.
2+
3+
![Bluey MeArm](images/bluey-mearm-sm.jpg)
4+
5+
This is an example project to demonstrate the use of Bluey to control MeArm over BLE.
6+
7+
MeArm is a compact robotic arm with four degrees of freedom. The four degrees of freedom allow MeArm to rotate on its base, while its arm can extend horizontally and vertically and its claws can be opened and closed to grab objects.
8+
MeArm design files can be found [here](https://github.com/mimeindustries/MeArm) and instructions on building your MeArm can be fund [here](http://learn.mime.co.uk/docs/control-your-mearm-from-arduino/)
9+
10+
In our application, we use Bluey as the processing unit to control MeArm and as wireless communication unit to obtain data from a smartphone. Using nRF ToolBox, eight different states are configured - 2 states for each motor, to move the motor in two different directions; that facilitates controlling the motion of MeArm.
11+
12+
#### Compiling
13+
14+
* Copy *bluey-MeArm* directory in *nRF5_SDK_12.2.0_f012efa\examples\ble_peripheral*.
15+
* Open *nRF5_SDK_12.2.0_f012efa\examples\ble_peripheral\bluey-MeArm\bluey1.2\s132\armgcc* in command prompt.
16+
* Issue `make` command to compile the program.
17+
* Issue `make dfupkg` to generate zip package.
18+
* The generated package is used to perform over-the-air(OTA) device firmware update (DFU). Follow instructions mentioned [here](../ota-prog.md) for detailed description on OTA programming to upload firmware to bluey.
19+
20+
21+
#### Connections
22+
23+
Motor | Pin
24+
----- | ---
25+
VCC | 5V
26+
GND | GND
27+
PWM (Base Servo) | 27
28+
PWM (Left Servo) | 28
29+
PWM (Right Servo)| 29
30+
PWM (Claw Servo) | 30
31+
32+
*Note!* Do not power the servo motors from bluey directly as the current draw of 4 servo motors is high and cannot be supported by the board. Use a dedicated power supply unit instead.
33+
34+
Testing:
35+
36+
* Power up Bluey.
37+
* Download and Install nRF Toolbox from Play Store. Run the application.
38+
* Select **UART** tab.
39+
* Press on **Connect** tab to scan for devices.
40+
41+
![](images/connect.jpg)
42+
43+
* Select **Bluey-MeArm** from available devices.
44+
45+
![](images/scan.jpg)
46+
47+
* On successful connection, **Bluey-MeArm** is seen on the screen.
48+
49+
![](images/Bluey-Mearm.jpg)
50+
51+
* Configure buttons by clicking the **Edit** tab on top-right corner of the mobile app.
52+
53+
* Select any button, choose an icon indicating this button and enter the value as shown in image below. Click on **Ok** followed by **Done** tab to save your changes.
54+
55+
![](images/config.jpg)
56+
57+
* Create 8 such buttons with following values.
58+
59+
Icon | Value
60+
---- | -----
61+
Up arrow (^) | leftOut
62+
Right arrow (>) | baseCW
63+
Left arrow (<) | baseCCW
64+
Down arrow | leftIn
65+
1 | rightA
66+
2 | rightB
67+
3 | clawOpen
68+
4 | clawClose
69+
70+
* Pressing any one of these buttons, will result in corresponding change in the position of the servo associated with the button.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
PROJECT_NAME := bluey1.2_s132
2+
TARGETS := nrf52832_xxaa
3+
OUTPUT_DIRECTORY := _build
4+
5+
SDK_ROOT := ../../../../../..
6+
PROJ_DIR := ../../..
7+
8+
$(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \
9+
LINKER_SCRIPT := ble_app_uart_gcc_nrf52.ld
10+
11+
# Source files common to all targets
12+
SRC_FILES += \
13+
$(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \
14+
$(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \
15+
$(SDK_ROOT)/components/libraries/button/app_button.c \
16+
$(SDK_ROOT)/components/libraries/util/app_error.c \
17+
$(SDK_ROOT)/components/libraries/util/app_error_weak.c \
18+
$(SDK_ROOT)/components/libraries/fifo/app_fifo.c \
19+
$(SDK_ROOT)/components/libraries/pwm/app_pwm.c \
20+
$(SDK_ROOT)/components/libraries/timer/app_timer.c \
21+
$(SDK_ROOT)/components/libraries/uart/app_uart_fifo.c \
22+
$(SDK_ROOT)/components/libraries/util/app_util_platform.c \
23+
$(SDK_ROOT)/components/libraries/fstorage/fstorage.c \
24+
$(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c \
25+
$(SDK_ROOT)/components/libraries/util/nrf_assert.c \
26+
$(SDK_ROOT)/components/libraries/uart/retarget.c \
27+
$(SDK_ROOT)/components/libraries/util/sdk_errors.c \
28+
$(SDK_ROOT)/components/boards/boards.c \
29+
$(SDK_ROOT)/components/drivers_nrf/clock/nrf_drv_clock.c \
30+
$(SDK_ROOT)/components/drivers_nrf/common/nrf_drv_common.c \
31+
$(SDK_ROOT)/components/drivers_nrf/gpiote/nrf_drv_gpiote.c \
32+
$(SDK_ROOT)/components/drivers_nrf/ppi/nrf_drv_ppi.c \
33+
$(SDK_ROOT)/components/drivers_nrf/timer/nrf_drv_timer.c \
34+
$(SDK_ROOT)/components/drivers_nrf/uart/nrf_drv_uart.c \
35+
$(SDK_ROOT)/components/libraries/bsp/bsp.c \
36+
$(SDK_ROOT)/components/libraries/bsp/bsp_btn_ble.c \
37+
$(SDK_ROOT)/components/libraries/bsp/bsp_nfc.c \
38+
$(PROJ_DIR)/main.c \
39+
$(SDK_ROOT)/external/segger_rtt/RTT_Syscalls_GCC.c \
40+
$(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
41+
$(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
42+
$(SDK_ROOT)/components/ble/common/ble_advdata.c \
43+
$(SDK_ROOT)/components/ble/ble_advertising/ble_advertising.c \
44+
$(SDK_ROOT)/components/ble/common/ble_conn_params.c \
45+
$(SDK_ROOT)/components/ble/common/ble_srv_common.c \
46+
$(SDK_ROOT)/components/toolchain/gcc/gcc_startup_nrf52.S \
47+
$(SDK_ROOT)/components/toolchain/system_nrf52.c \
48+
$(SDK_ROOT)/components/ble/ble_services/ble_nus/ble_nus.c \
49+
$(SDK_ROOT)/components/softdevice/common/softdevice_handler/softdevice_handler.c \
50+
51+
# Include folders common to all targets
52+
INC_FOLDERS += \
53+
$(SDK_ROOT)/components/drivers_nrf/comp \
54+
$(SDK_ROOT)/components/drivers_nrf/twi_master \
55+
$(SDK_ROOT)/components/ble/ble_services/ble_ancs_c \
56+
$(SDK_ROOT)/components/ble/ble_services/ble_ias_c \
57+
$(SDK_ROOT)/components/libraries/pwm \
58+
$(SDK_ROOT)/components/softdevice/s132/headers/nrf52 \
59+
$(SDK_ROOT)/components/libraries/usbd/class/cdc/acm \
60+
$(SDK_ROOT)/components/libraries/usbd/class/hid/generic \
61+
$(SDK_ROOT)/components/libraries/usbd/class/msc \
62+
$(SDK_ROOT)/components/libraries/usbd/class/hid \
63+
$(SDK_ROOT)/components/libraries/log \
64+
$(SDK_ROOT)/components/ble/ble_services/ble_gls \
65+
$(SDK_ROOT)/components/libraries/fstorage \
66+
$(SDK_ROOT)/components/drivers_nrf/i2s \
67+
$(SDK_ROOT)/components/libraries/gpiote \
68+
$(SDK_ROOT)/components/drivers_nrf/gpiote \
69+
$(SDK_ROOT)/components/libraries/fifo \
70+
$(SDK_ROOT)/components/boards \
71+
$(SDK_ROOT)/components/drivers_nrf/common \
72+
$(SDK_ROOT)/components/ble/ble_advertising \
73+
$(SDK_ROOT)/components/drivers_nrf/adc \
74+
$(SDK_ROOT)/components/ble/ble_services/ble_bas_c \
75+
$(SDK_ROOT)/components/ble/ble_services/ble_hrs_c \
76+
$(SDK_ROOT)/components/libraries/queue \
77+
$(SDK_ROOT)/components/ble/ble_dtm \
78+
$(SDK_ROOT)/components/toolchain/cmsis/include \
79+
$(SDK_ROOT)/components/ble/ble_services/ble_rscs_c \
80+
$(SDK_ROOT)/components/drivers_nrf/uart \
81+
$(SDK_ROOT)/components/ble/common \
82+
$(SDK_ROOT)/components/ble/ble_services/ble_lls \
83+
$(SDK_ROOT)/components/drivers_nrf/wdt \
84+
$(SDK_ROOT)/components/libraries/bsp \
85+
$(SDK_ROOT)/components/ble/ble_services/ble_bas \
86+
$(SDK_ROOT)/components/libraries/experimental_section_vars \
87+
$(SDK_ROOT)/components/softdevice/s132/headers \
88+
$(SDK_ROOT)/components/ble/ble_services/ble_ans_c \
89+
$(SDK_ROOT)/components/libraries/slip \
90+
$(SDK_ROOT)/components/libraries/mem_manager \
91+
$(SDK_ROOT)/external/segger_rtt \
92+
$(SDK_ROOT)/components/libraries/csense_drv \
93+
$(SDK_ROOT)/components/drivers_nrf/hal \
94+
$(SDK_ROOT)/components/ble/ble_services/ble_nus_c \
95+
$(SDK_ROOT)/components/drivers_nrf/rtc \
96+
$(SDK_ROOT)/components/ble/ble_services/ble_ias \
97+
$(SDK_ROOT)/components/libraries/usbd/class/hid/mouse \
98+
$(SDK_ROOT)/components/drivers_nrf/ppi \
99+
$(SDK_ROOT)/components/ble/ble_services/ble_dfu \
100+
$(SDK_ROOT)/components/drivers_nrf/twis_slave \
101+
$(SDK_ROOT)/components \
102+
$(SDK_ROOT)/components/libraries/scheduler \
103+
$(SDK_ROOT)/components/ble/ble_services/ble_lbs \
104+
$(SDK_ROOT)/components/ble/ble_services/ble_hts \
105+
$(SDK_ROOT)/components/drivers_nrf/delay \
106+
$(SDK_ROOT)/components/libraries/crc16 \
107+
$(SDK_ROOT)/components/drivers_nrf/timer \
108+
$(SDK_ROOT)/components/libraries/util \
109+
$(SDK_ROOT)/components/drivers_nrf/pwm \
110+
../config \
111+
$(SDK_ROOT)/components/libraries/usbd/class/cdc \
112+
$(SDK_ROOT)/components/libraries/csense \
113+
$(SDK_ROOT)/components/drivers_nrf/rng \
114+
$(SDK_ROOT)/components/libraries/low_power_pwm \
115+
$(SDK_ROOT)/components/libraries/hardfault \
116+
$(SDK_ROOT)/components/ble/ble_services/ble_cscs \
117+
$(SDK_ROOT)/components/libraries/uart \
118+
$(SDK_ROOT)/components/libraries/hci \
119+
$(SDK_ROOT)/components/libraries/usbd/class/hid/kbd \
120+
$(SDK_ROOT)/components/drivers_nrf/spi_slave \
121+
$(SDK_ROOT)/components/drivers_nrf/lpcomp \
122+
$(SDK_ROOT)/components/libraries/timer \
123+
$(SDK_ROOT)/components/drivers_nrf/power \
124+
$(SDK_ROOT)/components/libraries/usbd/config \
125+
$(SDK_ROOT)/components/toolchain \
126+
$(SDK_ROOT)/components/libraries/led_softblink \
127+
$(SDK_ROOT)/components/drivers_nrf/qdec \
128+
$(SDK_ROOT)/components/ble/ble_services/ble_cts_c \
129+
$(SDK_ROOT)/components/drivers_nrf/spi_master \
130+
$(SDK_ROOT)/components/ble/ble_services/ble_nus \
131+
$(SDK_ROOT)/components/ble/ble_services/ble_hids \
132+
$(SDK_ROOT)/components/drivers_nrf/pdm \
133+
$(SDK_ROOT)/components/libraries/crc32 \
134+
$(SDK_ROOT)/components/libraries/usbd/class/audio \
135+
$(SDK_ROOT)/components/ble/peer_manager \
136+
$(SDK_ROOT)/components/drivers_nrf/swi \
137+
$(SDK_ROOT)/components/ble/ble_services/ble_tps \
138+
$(SDK_ROOT)/components/ble/ble_services/ble_dis \
139+
$(SDK_ROOT)/components/device \
140+
$(SDK_ROOT)/components/ble/nrf_ble_qwr \
141+
$(SDK_ROOT)/components/libraries/button \
142+
$(SDK_ROOT)/components/libraries/usbd \
143+
$(SDK_ROOT)/components/drivers_nrf/saadc \
144+
$(SDK_ROOT)/components/ble/ble_services/ble_lbs_c \
145+
$(SDK_ROOT)/components/ble/ble_racp \
146+
$(SDK_ROOT)/components/toolchain/gcc \
147+
$(SDK_ROOT)/components/libraries/fds \
148+
$(SDK_ROOT)/components/libraries/twi \
149+
$(SDK_ROOT)/components/drivers_nrf/clock \
150+
$(SDK_ROOT)/components/ble/ble_services/ble_rscs \
151+
$(SDK_ROOT)/components/drivers_nrf/usbd \
152+
$(SDK_ROOT)/components/softdevice/common/softdevice_handler \
153+
$(SDK_ROOT)/components/ble/ble_services/ble_hrs \
154+
$(SDK_ROOT)/components/libraries/log/src \
155+
156+
# Libraries common to all targets
157+
LIB_FILES += \
158+
159+
# C flags common to all targets
160+
CFLAGS += -DNRF52
161+
CFLAGS += -DNRF52_PAN_64
162+
CFLAGS += -DSOFTDEVICE_PRESENT
163+
CFLAGS += -DBOARD_PCA10040
164+
CFLAGS += -DNRF52832
165+
CFLAGS += -DNRF52_PAN_12
166+
CFLAGS += -DNRF52_PAN_58
167+
CFLAGS += -DNRF52_PAN_54
168+
CFLAGS += -DNRF52_PAN_31
169+
CFLAGS += -DNRF52_PAN_51
170+
CFLAGS += -DNRF52_PAN_36
171+
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
172+
CFLAGS += -DBLE_STACK_SUPPORT_REQD
173+
CFLAGS += -DNRF52_PAN_15
174+
CFLAGS += -DNRF_SD_BLE_API_VERSION=3
175+
CFLAGS += -DSWI_DISABLE0
176+
CFLAGS += -DNRF52_PAN_20
177+
CFLAGS += -DNRF52_PAN_55
178+
CFLAGS += -DS132
179+
CFLAGS += -mcpu=cortex-m4
180+
CFLAGS += -mthumb -mabi=aapcs
181+
CFLAGS += -Wall -Werror -O0 -g3
182+
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
183+
# keep every function in separate section, this allows linker to discard unused ones
184+
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
185+
CFLAGS += -fno-builtin --short-enums
186+
187+
# C++ flags common to all targets
188+
CXXFLAGS += \
189+
190+
# Assembler flags common to all targets
191+
ASMFLAGS += -x assembler-with-cpp
192+
ASMFLAGS += -DNRF52
193+
ASMFLAGS += -DNRF52_PAN_64
194+
ASMFLAGS += -DSOFTDEVICE_PRESENT
195+
ASMFLAGS += -DBOARD_PCA10040
196+
ASMFLAGS += -DNRF52832
197+
ASMFLAGS += -DNRF52_PAN_12
198+
ASMFLAGS += -DNRF52_PAN_58
199+
ASMFLAGS += -DNRF52_PAN_54
200+
ASMFLAGS += -DNRF52_PAN_31
201+
ASMFLAGS += -DNRF52_PAN_51
202+
ASMFLAGS += -DNRF52_PAN_36
203+
ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
204+
ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
205+
ASMFLAGS += -DNRF52_PAN_15
206+
ASMFLAGS += -DNRF_SD_BLE_API_VERSION=3
207+
ASMFLAGS += -DSWI_DISABLE0
208+
ASMFLAGS += -DNRF52_PAN_20
209+
ASMFLAGS += -DNRF52_PAN_55
210+
ASMFLAGS += -DS132
211+
212+
# Linker flags
213+
LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
214+
LDFLAGS += -mcpu=cortex-m4
215+
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
216+
# let linker to dump unused sections
217+
LDFLAGS += -Wl,--gc-sections
218+
# use newlib in nano version
219+
LDFLAGS += --specs=nano.specs -lc -lnosys
220+
221+
222+
.PHONY: $(TARGETS) default all clean help flash flash_softdevice
223+
224+
# Default target - first one defined
225+
default: nrf52832_xxaa
226+
227+
# Print all targets that can be built
228+
help:
229+
@echo following targets are available:
230+
@echo nrf52832_xxaa
231+
232+
TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
233+
234+
include $(TEMPLATE_PATH)/Makefile.common
235+
236+
$(foreach target, $(TARGETS), $(call define_target, $(target)))
237+
238+
# Flash the program
239+
flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex
240+
@echo Flashing: $<
241+
nrfjprog --program $< -f nrf52 --sectorerase
242+
nrfjprog --reset -f nrf52
243+
244+
# Flash softdevice
245+
flash_softdevice:
246+
@echo Flashing: s132_nrf52_3.0.0_softdevice.hex
247+
nrfjprog --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_3.0.0_softdevice.hex -f nrf52 --sectorerase
248+
nrfjprog --reset -f nrf52
249+
250+
# make DFU package
251+
dfupkg:
252+
@echo Generating DFU package...
253+
nrfutil pkg generate --hw-version 52 --application-version 1 --application $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex --sd-req 0x8C --key-file ../../../private.key ../../../bluey_MeArm_dfu_package.zip
254+
255+
erase:
256+
nrfjprog --eraseall -f nrf52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* Linker script to configure memory regions. */
2+
3+
SEARCH_DIR(.)
4+
GROUP(-lgcc -lc -lnosys)
5+
6+
MEMORY
7+
{
8+
FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000
9+
RAM (rwx) : ORIGIN = 0x20002128, LENGTH = 0xded8
10+
}
11+
12+
SECTIONS
13+
{
14+
.fs_data :
15+
{
16+
PROVIDE(__start_fs_data = .);
17+
KEEP(*(.fs_data))
18+
PROVIDE(__stop_fs_data = .);
19+
} > RAM
20+
.pwr_mgmt_data :
21+
{
22+
PROVIDE(__start_pwr_mgmt_data = .);
23+
KEEP(*(.pwr_mgmt_data))
24+
PROVIDE(__stop_pwr_mgmt_data = .);
25+
} > RAM
26+
} INSERT AFTER .data;
27+
28+
INCLUDE "nrf5x_common.ld"

0 commit comments

Comments
 (0)