├── .gitignore ├── LICENSE ├── README.md ├── nRF51822 ├── Makefile.common ├── blank_nrf51822_QFAA.ld ├── blank_nrf51822_QFAB.ld ├── blank_nrf51822_QFAC.ld ├── ble_app_beacon │ ├── Makefile │ ├── Makefile.S130 │ ├── flash.txt │ ├── license.txt │ ├── main.c │ └── nrf_drv_config.h ├── ble_app_beacon_12.2 │ ├── Makefile │ ├── Makefile.S130 │ ├── license.txt │ ├── main.c │ └── sdk_config.h ├── ble_app_beacon_12 │ ├── Makefile │ ├── Makefile.S130 │ ├── flash.txt │ ├── license.txt │ ├── main.c │ └── sdk_config.h ├── ble_app_beacon_lowpower │ ├── Makefile │ ├── Makefile.S130 │ ├── flash.txt │ ├── license.txt │ ├── main.c │ └── nrf_drv_config.h ├── ble_app_beacon_lowpower_12 │ ├── Makefile │ ├── Makefile.S130 │ ├── flash.txt │ ├── license.txt │ ├── main.c │ └── sdk_config.h ├── ble_app_max6675 │ ├── .cproject │ ├── .gitignore │ ├── .project │ ├── .settings │ │ └── language.settings.xml │ ├── Makefile │ ├── ble_max6675.c │ ├── ble_max6675.h │ ├── custom_board.h │ ├── flash.txt │ ├── main.c │ ├── max6675.c │ ├── max6675.h │ └── sdk_config.h ├── ble_app_mcp3008 │ ├── .cproject │ ├── .project │ ├── .settings │ │ └── language.settings.xml │ ├── Makefile │ ├── ble_mcp3008.c │ ├── ble_mcp3008.h │ ├── custom_board.h │ ├── main.c │ ├── mcp3008.c │ ├── mcp3008.h │ └── sdk_config.h ├── ble_app_si7021 │ ├── .cproject │ ├── .gitignore │ ├── .project │ ├── .settings │ │ └── language.settings.xml │ ├── Makefile │ ├── ble_si7021.c │ ├── ble_si7021.h │ ├── custom_board.h │ ├── flash.txt │ ├── main.c │ └── sdk_config.h ├── ble_test_board.h ├── blinky │ ├── .gitignore │ ├── Makefile │ ├── blinky.c │ └── flash.txt ├── custom_board.h ├── dfu_app │ ├── Makefile │ ├── Makefile.S130 │ ├── main.c │ └── sdk_config.h ├── dfu_secure │ ├── Makefile │ ├── Makefile.S130 │ ├── sdk_config.h │ └── secure_dfu_gcc_nrf51_QFAC_debug.ld ├── flash_nrf.php ├── gpiote │ ├── Makefile │ ├── flash.txt │ ├── main.c │ └── nrf_drv_config.h ├── openocd.cfg ├── qdec_rotary_encoder │ ├── Makefile │ ├── flash.txt │ ├── main.c │ ├── nrf_drv_config.h │ ├── uart.c │ └── uart.h ├── rtc_blinky │ ├── Makefile │ ├── flash.txt │ ├── nrf_drv_config.h │ └── rtc_blinky.c ├── s110_nrf51822_QFAA.ld ├── s110_nrf51822_QFAC.ld ├── s130_nrf51822_QFAA.ld ├── s130_nrf51822_QFAC.ld ├── s130_v2_nrf51822_QFAA.ld ├── s130_v2_nrf51822_QFAC.ld ├── spi_ili9341 │ ├── Makefile │ ├── flash.txt │ ├── ili9341.c │ ├── ili9341.h │ ├── main.c │ ├── sdk_config.h │ ├── stm32_main.c │ ├── tm_stm32f4_fonts.c │ ├── tm_stm32f4_fonts.h │ ├── xprintf.c │ └── xprintf.h ├── spi_ili9341_ucglib │ ├── .cproject │ ├── .project │ ├── .settings │ │ └── language.settings.xml │ ├── Makefile │ ├── main.c │ ├── sdk_config.h │ ├── ucg_nrf51822.c │ └── ucg_nrf51822.h ├── spi_max6675 │ ├── .cproject │ ├── .project │ ├── .settings │ │ └── language.settings.xml │ ├── Makefile │ ├── custom_board.h │ ├── main.c │ ├── max6675.c │ ├── max6675.h │ └── sdk_config.h ├── spi_max7221 │ ├── Makefile │ ├── flash.txt │ ├── glcdfont.h │ ├── main.c │ ├── max7221.c │ ├── max7221.h │ └── sdk_config.h ├── timer_blinky │ ├── Makefile │ ├── flash.txt │ ├── nrf_drv_config.h │ └── timer_blinky.c ├── timer_servo │ ├── Makefile │ ├── flash.txt │ ├── nrf_drv_config.h │ └── timer_servo.c ├── ttp229_gpiote │ ├── Makefile │ ├── flash.txt │ ├── nrf_drv_config.h │ ├── ttp229_gpiote.c │ ├── uart.c │ └── uart.h └── uart │ ├── Makefile │ ├── flash.txt │ ├── main.c │ ├── nrf_drv_config.h │ ├── readme.txt │ ├── uart.c │ └── uart.h ├── nRF52832 ├── Makefile.common ├── Testboard.txt ├── blank_nrf52832_QFAA.ld ├── blinky │ ├── .gitignore │ ├── Makefile │ └── main.c ├── board1.jpg └── openocd_nrf52.cfg └── nRF52840 ├── Makefile.common ├── blank_nrf52840_QFIA.ld ├── ble_app_beacon_13 ├── Makefile ├── Makefile.S140 ├── license.txt ├── main.c ├── s140_v2_nrf52840_QIAA.ld └── sdk_config.h ├── blinky_13 ├── .cproject ├── .project ├── .settings │ └── language.settings.xml ├── Makefile ├── main.c └── sdk_config.h └── custom_board.h /.gitignore: -------------------------------------------------------------------------------- 1 | flash.txt 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nordic 2 | Nordic stuff 3 | -------------------------------------------------------------------------------- /nRF51822/blank_nrf51822_QFAA.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x40000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data_out ALIGN(4): 15 | { 16 | PROVIDE( __start_fs_data = .); 17 | KEEP(*(fs_data)) 18 | PROVIDE( __stop_fs_data = .); 19 | } = 0 20 | } 21 | 22 | INCLUDE "nrf5x_common.ld" -------------------------------------------------------------------------------- /nRF51822/blank_nrf51822_QFAB.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x20000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data_out ALIGN(4): 15 | { 16 | PROVIDE( __start_fs_data = .); 17 | KEEP(*(fs_data)) 18 | PROVIDE( __stop_fs_data = .); 19 | } = 0 20 | } 21 | 22 | INCLUDE "nrf5x_common.ld" -------------------------------------------------------------------------------- /nRF51822/blank_nrf51822_QFAC.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY { 7 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x40000 8 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 9 | } 10 | 11 | SECTIONS { 12 | .fs_data_out ALIGN(4): 13 | { 14 | PROVIDE( __start_fs_data = .); 15 | KEEP(*(fs_data)) 16 | PROVIDE( __stop_fs_data = .); 17 | } = 0 18 | } 19 | 20 | INCLUDE "nrf5x_common.ld" 21 | -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon/Makefile: -------------------------------------------------------------------------------- 1 | Makefile.S130 -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon/Makefile.S130: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS = -DNRF_LOG_USES_UART=1 7 | CFLAGS += -DSOFTDEVICE_PRESENT 8 | CFLAGS += -DS130 9 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 10 | CFLAGS += -DSWI_DISABLE0 11 | CFLAGS += -DBOARD_BLE_TEST 12 | ASFLAGS += -g 13 | ASMFLAGS += -DNRF_LOG_USES_UART=1 14 | ASMFLAGS += -DSOFTDEVICE_PRESENT 15 | ASMFLAGS += -DS130 16 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 17 | ASMFLAGS += -DSWI_DISABLE0 18 | ASMFLAGS += -DBOARD_BLE_TEST 19 | #LDLIBS += -lc -lgcc -lrdimon 20 | 21 | LDSCRIPT = $(TEMPLATEROOT)/s130_nrf51822_QFAA.ld 22 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s130/headers 23 | 24 | vpath %.c $(SDK_PATH)/components/softdevice/s130/headers 25 | 26 | # object files 27 | 28 | OBJS = app_button.o app_error.o app_fifo.o app_timer.o app_util_platform.o nrf_assert.o nrf_log.o 29 | OBJS += retarget.o app_uart_fifo.o 30 | OBJS += nrf_delay.o nrf_drv_common.o nrf_drv_gpiote.o nrf_drv_uart.o 31 | OBJS += bsp.o main.o 32 | OBJS += ble_advdata.o ble_conn_params.o ble_srv_common.o 33 | OBJS += system_nrf51.o softdevice_handler.o 34 | # include common make file 35 | 36 | include $(TEMPLATEROOT)/Makefile.common 37 | -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon/flash.txt: -------------------------------------------------------------------------------- 1 | openocd -d3 -f ../openocd.cfg 2 | telnet 127.0.0.1 4444 3 | reset halt 4 | nrf51 mass_erase 5 | program /home/pcbreflux/nordic/s130_nrf51_1.0.0_API/s130_nrf51_1.0.0_softdevice.hex verify 6 | reset halt 7 | program /home/pcbreflux/nordic/nordic.git/nRF51822/ble_app_beacon/_build/ble_app_beacon.hex verify 8 | reset 9 | 10 | 11 | -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pcbreflux/nordic/7094312fe7913cde2ad25ce3926fe5dfad35948a/nRF51822/ble_app_beacon/license.txt -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_12.2/Makefile: -------------------------------------------------------------------------------- 1 | Makefile.S130 -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_12.2/Makefile.S130: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_PCA10028 7 | CFLAGS += -DNRF51822 8 | CFLAGS += -DNRF_LOG_USES_UART=1 9 | CFLAGS += -DSOFTDEVICE_PRESENT 10 | CFLAGS += -DS130 11 | CFLAGS += -DNRF_SD_BLE_API_VERSION=2 12 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 13 | CFLAGS += -DSWI_DISABLE0 14 | ASMFLAGS += -g 15 | ASMFLAGS += -DBOARD_PCA10028 16 | ASMFLAGS += -DNRF51822 17 | ASMFLAGS += -DNRF_LOG_USES_UART=1 18 | ASMFLAGS += -DSOFTDEVICE_PRESENT 19 | ASMFLAGS += -DS130 20 | ASMFLAGS += -DNRF_SD_BLE_API_VERSION=2 21 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 22 | ASMFLAGS += -DSWI_DISABLE0 23 | 24 | LDSCRIPT = $(TEMPLATEROOT)/s130_v2_nrf51822_QFAA.ld 25 | 26 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s130/headers 27 | 28 | vpath %.c $(SDK_PATH)/components/softdevice/s130/headers 29 | 30 | # object files 31 | 32 | OBJS = nrf_log_backend_serial.o nrf_log_frontend.o 33 | OBJS += app_button.o app_error.o app_error_weak.o app_fifo.o app_timer.o app_util_platform.o 34 | OBJS += hardfault_implementation.o nrf_assert.o 35 | OBJS += nrf_drv_clock.o nrf_drv_common.o nrf_drv_gpiote.o nrf_drv_uart.o 36 | OBJS += bsp.o boards.o main.o 37 | OBJS += ble_advdata.o ble_conn_params.o ble_srv_common.o 38 | OBJS += system_nrf51.o softdevice_handler.o 39 | # include common make file 40 | 41 | include $(TEMPLATEROOT)/Makefile.common 42 | -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_12.2/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pcbreflux/nordic/7094312fe7913cde2ad25ce3926fe5dfad35948a/nRF51822/ble_app_beacon_12.2/license.txt -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_12/Makefile: -------------------------------------------------------------------------------- 1 | Makefile.S130 -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_12/Makefile.S130: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF51822 8 | CFLAGS += -DNRF_LOG_USES_UART=1 9 | CFLAGS += -DSOFTDEVICE_PRESENT 10 | CFLAGS += -DS130 11 | CFLAGS += -DNRF_SD_BLE_API_VERSION=2 12 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 13 | CFLAGS += -DSWI_DISABLE0 14 | ASMFLAGS += -g 15 | ASMFLAGS += -DBOARD_CUSTOM 16 | ASMFLAGS += -DNRF51822 17 | ASMFLAGS += -DNRF_LOG_USES_UART=1 18 | ASMFLAGS += -DSOFTDEVICE_PRESENT 19 | ASMFLAGS += -DS130 20 | ASMFLAGS += -DNRF_SD_BLE_API_VERSION=2 21 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 22 | ASMFLAGS += -DSWI_DISABLE0 23 | 24 | LDSCRIPT = $(TEMPLATEROOT)/s130_v2_nrf51822_QFAA.ld 25 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s130/headers 26 | 27 | vpath %.c $(SDK_PATH)/components/softdevice/s130/headers 28 | 29 | # object files 30 | 31 | OBJS = nrf_log_backend_serial.o nrf_log_frontend.o 32 | OBJS += app_button.o app_error.o app_error_weak.o app_fifo.o app_timer.o app_util_platform.o 33 | OBJS += hardfault_implementation.o nrf_assert.o 34 | OBJS += nrf_drv_clock.o nrf_drv_common.o nrf_drv_gpiote.o nrf_drv_uart.o 35 | OBJS += bsp.o main.o 36 | OBJS += ble_advdata.o ble_conn_params.o ble_srv_common.o 37 | OBJS += system_nrf51.o softdevice_handler.o 38 | # include common make file 39 | 40 | include $(TEMPLATEROOT)/Makefile.common 41 | -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_12/flash.txt: -------------------------------------------------------------------------------- 1 | make flash_s130 2 | -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_12/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pcbreflux/nordic/7094312fe7913cde2ad25ce3926fe5dfad35948a/nRF51822/ble_app_beacon_12/license.txt -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_lowpower/Makefile: -------------------------------------------------------------------------------- 1 | Makefile.S130 -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_lowpower/Makefile.S130: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS = -DNRF_LOG_USES_UART=1 7 | CFLAGS += -DSOFTDEVICE_PRESENT 8 | CFLAGS += -DS130 9 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 10 | CFLAGS += -DSWI_DISABLE0 11 | CFLAGS += -DBOARD_BLE_TEST 12 | ASFLAGS += -g 13 | ASMFLAGS += -DNRF_LOG_USES_UART=1 14 | ASMFLAGS += -DSOFTDEVICE_PRESENT 15 | ASMFLAGS += -DS130 16 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 17 | ASMFLAGS += -DSWI_DISABLE0 18 | ASMFLAGS += -DBOARD_BLE_TEST 19 | #LDLIBS += -lc -lgcc -lrdimon 20 | 21 | LDSCRIPT = $(TEMPLATEROOT)/s130_nrf51822_QFAA.ld 22 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s130/headers 23 | 24 | vpath %.c $(SDK_PATH)/components/softdevice/s130/headers 25 | 26 | # object files 27 | 28 | OBJS = app_button.o app_error.o app_fifo.o app_timer.o app_util_platform.o nrf_assert.o nrf_log.o 29 | OBJS += retarget.o app_uart_fifo.o 30 | OBJS += nrf_delay.o nrf_drv_common.o nrf_drv_gpiote.o nrf_drv_uart.o 31 | OBJS += bsp.o main.o 32 | OBJS += ble_advdata.o ble_conn_params.o ble_srv_common.o 33 | OBJS += system_nrf51.o softdevice_handler.o 34 | # include common make file 35 | 36 | include $(TEMPLATEROOT)/Makefile.common 37 | -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_lowpower/flash.txt: -------------------------------------------------------------------------------- 1 | openocd -d3 -f ../openocd.cfg 2 | telnet 127.0.0.1 4444 3 | reset halt 4 | nrf51 mass_erase 5 | program /home/pcbreflux/nordic/s130_nrf51_1.0.0_API/s130_nrf51_1.0.0_softdevice.hex verify 6 | reset halt 7 | program /home/pcbreflux/nordic/nordic.git/nRF51822/ble_app_beacon/_build/ble_app_beacon.hex verify 8 | reset 9 | 10 | 11 | -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_lowpower/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pcbreflux/nordic/7094312fe7913cde2ad25ce3926fe5dfad35948a/nRF51822/ble_app_beacon_lowpower/license.txt -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_lowpower_12/Makefile: -------------------------------------------------------------------------------- 1 | Makefile.S130 -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_lowpower_12/Makefile.S130: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF51822 8 | CFLAGS += -DNRF_LOG_USES_UART=1 9 | CFLAGS += -DSOFTDEVICE_PRESENT 10 | CFLAGS += -DS130 11 | CFLAGS += -DNRF_SD_BLE_API_VERSION=2 12 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 13 | CFLAGS += -DSWI_DISABLE0 14 | ASMFLAGS += -g 15 | ASMFLAGS += -DBOARD_CUSTOM 16 | ASMFLAGS += -DNRF51822 17 | ASMFLAGS += -DNRF_LOG_USES_UART=1 18 | ASMFLAGS += -DSOFTDEVICE_PRESENT 19 | ASMFLAGS += -DS130 20 | ASMFLAGS += -DNRF_SD_BLE_API_VERSION=2 21 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 22 | ASMFLAGS += -DSWI_DISABLE0 23 | 24 | LDSCRIPT = $(TEMPLATEROOT)/s130_v2_nrf51822_QFAA.ld 25 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s130/headers 26 | 27 | vpath %.c $(SDK_PATH)/components/softdevice/s130/headers 28 | 29 | # object files 30 | 31 | OBJS = nrf_log_backend_serial.o nrf_log_frontend.o 32 | OBJS += app_button.o app_error.o app_error_weak.o app_fifo.o app_timer.o app_util_platform.o 33 | OBJS += hardfault_implementation.o nrf_assert.o 34 | OBJS += nrf_drv_clock.o nrf_drv_common.o nrf_drv_gpiote.o nrf_drv_uart.o 35 | OBJS += bsp.o main.o 36 | OBJS += ble_advdata.o ble_conn_params.o ble_srv_common.o 37 | OBJS += system_nrf51.o softdevice_handler.o 38 | # include common make file 39 | 40 | include $(TEMPLATEROOT)/Makefile.common 41 | -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_lowpower_12/flash.txt: -------------------------------------------------------------------------------- 1 | make flash_s130 2 | -------------------------------------------------------------------------------- /nRF51822/ble_app_beacon_lowpower_12/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pcbreflux/nordic/7094312fe7913cde2ad25ce3926fe5dfad35948a/nRF51822/ble_app_beacon_lowpower_12/license.txt -------------------------------------------------------------------------------- /nRF51822/ble_app_max6675/.gitignore: -------------------------------------------------------------------------------- 1 | flash.txt 2 | -------------------------------------------------------------------------------- /nRF51822/ble_app_max6675/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ble_app_max6675 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | 26 | 27 | -------------------------------------------------------------------------------- /nRF51822/ble_app_max6675/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /nRF51822/ble_app_max6675/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF51822 8 | CFLAGS += -DNRF_LOG_USES_UART=1 9 | CFLAGS += -DSOFTDEVICE_PRESENT 10 | CFLAGS += -DS130 11 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 12 | CFLAGS += -DSWI_DISABLE0 13 | CFLAGS += -DNRF_SD_BLE_API_VERSION=2 14 | CFLAGS += -D__HEAP_SIZE=0 15 | ASFLAGS += -g 16 | ASMFLAGS += -DBOARD_CUSTOM 17 | ASMFLAGS += -DNRF51822 18 | ASMFLAGS += -DNRF_LOG_USES_UART=1 19 | ASMFLAGS += -DSOFTDEVICE_PRESENT 20 | ASMFLAGS += -DS130 21 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 22 | ASMFLAGS += -DSWI_DISABLE0 23 | ASMFLAGS += -DNRF_SD_BLE_API_VERSION=2 24 | ASMFLAGS += -D__HEAP_SIZE=0 25 | #LDLIBS += -lc -lgcc -lrdimon 26 | 27 | LDSCRIPT = $(TEMPLATEROOT)/s130_v2_nrf51822_QFAA.ld 28 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s130/headers 29 | 30 | vpath %.c $(SDK_PATH)/components/softdevice/s130/headers 31 | 32 | # object files 33 | 34 | OBJS += system_nrf51.o nrf_log_backend_serial.o nrf_log_frontend.o 35 | OBJS += app_error_weak.o app_error.o app_fifo.o app_util_platform.o nrf_assert.o app_uart_fifo.o 36 | OBJS += app_timer.o 37 | OBJS += nrf_drv_common.o nrf_drv_uart.o nrf_drv_spi.o nrf_drv_clock.o 38 | OBJS += bsp.o main.o fstorage.o fds.o sdk_mapped_flags.o 39 | OBJS += ble_advdata.o ble_advertising.o ble_conn_params.o 40 | OBJS += max6675.o ble_max6675.o ble_srv_common.o ble_conn_state.o 41 | OBJS += gatt_cache_manager.o gatts_cache_manager.o id_manager.o peer_data.o 42 | OBJS += peer_data_storage.o peer_database.o peer_id.o peer_manager.o 43 | OBJS += pm_buffer.o pm_mutex.o security_dispatcher.o security_manager.o 44 | OBJS += softdevice_handler.o 45 | # include common make file 46 | 47 | include $(TEMPLATEROOT)/Makefile.common 48 | -------------------------------------------------------------------------------- /nRF51822/ble_app_max6675/ble_max6675.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | /** @file ble_max6675.h 17 | * 18 | * @brief Temperature Service module. 19 | * 20 | * @details This module implements the MAX6675 Service with the MAX6675 characteristic. 21 | * During initialization it adds the MAX6675 Service and MAX6675 characteristic 22 | * to the BLE stack database. 23 | * 24 | * If specified, the module will support notification of the MAX6675 characteristic 25 | * through the ble_max6675_read() function. 26 | * If an event handler is supplied by the application, the MAX6675 Service will 27 | * generate MAX6675 Service events to the application. 28 | * 29 | * @note The application must propagate BLE stack events to the MAX6675 Service module by calling 30 | * ble_max6675_on_ble_evt() from the @ref softdevice_handler callback. 31 | * 32 | */ 33 | 34 | #ifndef BLE_MAX6675_H__ 35 | #define BLE_MAX6675_H__ 36 | 37 | #include 38 | #include 39 | #include "ble.h" 40 | #include "ble_srv_common.h" 41 | #include "app_util.h" 42 | 43 | // using random numbers via https://www.uuidgenerator.net/ 44 | #define BLE_MAX6675_UUID_BASE {0x18, 0x1B, 0xDB, 0x53, 0x32, 0x6C, 0x44, 0x23, \ 45 | 0xBB, 0x89, 0x65, 0x87, 0xAA, 0xEE, 0xEE, 0x07} 46 | #define BLE_MAX6675_UUID_SERVICE 0x3141 47 | #define BLE_MAX6675_UUID_COM_CHAR 0x3142 48 | #define BLE_MAX6675_UUID_VALUE_CHAR 0x3143 49 | 50 | #define BLE_MAX6675_COM_MAX_LEN 6 /* max number of bytes per BLE package */ 51 | #define BLE_MAX6675_VALUE_MAX_LEN sizeof(uint16_t) /* max number of bytes */ 52 | 53 | /**@brief MAX6675 Service event type. */ 54 | typedef enum { 55 | BLE_MAX6675_EVT_NOTIFICATION_ENABLED, /**< MAX6675 value notification enabled event. */ 56 | BLE_MAX6675_EVT_NOTIFICATION_DISABLED, /**< MAX6675 value notification disabled event. */ 57 | BLE_MAX6675_EVT_DISCONNECTED /**< MAX6675 value notification disconnected event. */ 58 | } ble_max6675_evt_type_t; 59 | 60 | /**@brief MAX6675 Service event. */ 61 | typedef struct { 62 | ble_max6675_evt_type_t evt_type; /**< Type of event. */ 63 | } ble_max6675_evt_t; 64 | 65 | // Forward declaration of the ble_max6675_t type. 66 | typedef struct ble_max6675_s ble_max6675_t; 67 | 68 | /**@brief MAX6675 Service event handler type. */ 69 | typedef void (*ble_max6675_evt_handler_t) (ble_max6675_t * p_max6675, ble_max6675_evt_t *evt); 70 | 71 | /**@brief MAX6675 Service init structure. This contains all options and data needed for 72 | * initialization of the service.*/ 73 | typedef struct { 74 | ble_max6675_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the MAX6675 Service. */ 75 | } ble_max6675_init_t; 76 | 77 | typedef enum { 78 | BLE_MAX6675_COM_START, /**< command truncate channel info. */ 79 | BLE_MAX6675_COM_STOP, /**< command truncate channel info. */ 80 | BLE_MAX6675_COM_NOTIFY /**< command truncate channel info. */ 81 | } ble_max6675_command_type_t; 82 | 83 | typedef enum { 84 | BLE_MAX6675_START_STOP, /**< command truncate channel info. */ 85 | BLE_MAX6675_START_TIMER, /**< command truncate channel info. */ 86 | BLE_MAX6675_START_PWM, /**< command truncate channel info. */ 87 | BLE_MAX6675_START_SOFTBLINK, /**< command truncate channel info. */ 88 | BLE_MAX6675_START_SERVO 89 | } ble_max6675_start_type_t; 90 | 91 | /**@brief MAX6675 Service structure. This contains various status information for the service. */ 92 | struct ble_max6675_s { 93 | uint16_t service_handle; /**< Handle of MAX6675 Service (as provided by the BLE stack). */ 94 | ble_gatts_char_handles_t com_char_handles; /**< Handles related to the adding characteristic. */ 95 | ble_gatts_char_handles_t value_char_handles; /**< Handles related to the notifying values characteristic. */ 96 | uint16_t report_ref_handle; /**< Handle of the Report Reference descriptor. */ 97 | uint8_t uuid_type; /**< UUID type for the MAX6675 Service. */ 98 | uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack). BLE_CONN_HANDLE_INVALID if not in a connection. */ 99 | ble_max6675_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the MAX6675 Service. */ 100 | uint16_t last_temp; /**< Temperature in 0.25 degrees celsius. */ 101 | uint8_t running; /**< Temperature in 0.25 degrees celsius. */ 102 | }; 103 | 104 | /**@brief Function for initializing the MAX6675 Service. 105 | * 106 | * @param[out] p_max6675 MAX6675 Service structure. This structure will have to be supplied by 107 | * the application. It will be initialized by this function, and will later 108 | * be used to identify this particular service instance. 109 | * @param[in] p_max6675_init Information needed to initialize the service. 110 | * 111 | * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. 112 | */ 113 | uint32_t ble_max6675_init(ble_max6675_t * p_max6675, const ble_max6675_init_t * p_max6675_init); 114 | 115 | /**@brief Function for handling the Application's BLE Stack events. 116 | * 117 | * @details Handles all events from the BLE stack of interest to the MAX6675 Service. 118 | * 119 | * @param[in] p_max6675 MAX6675 Service structure. 120 | * @param[in] p_ble_evt Event received from the BLE stack. 121 | */ 122 | void ble_max6675_on_ble_evt(ble_max6675_t * p_max6675, ble_evt_t * p_ble_evt); 123 | 124 | /**@brief Function for initializing the MAX6675 Service. 125 | * 126 | * @param[in] p_max6675 MAX6675 Service structure. 127 | * @param[in] temp Temperature in 0.25 degrees celsius. 128 | * 129 | * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. 130 | */ 131 | uint32_t ble_max6675_temp_update(ble_max6675_t * p_max6675, uint16_t temp); 132 | 133 | #endif // BLE_MAX6675_H__ 134 | 135 | /** @} */ 136 | -------------------------------------------------------------------------------- /nRF51822/ble_app_max6675/flash.txt: -------------------------------------------------------------------------------- 1 | openocd -d3 -f ../openocd.cfg 2 | telnet 127.0.0.1 4444 3 | reset halt 4 | nrf51 mass_erase 5 | program /home/sstern/nordic/s130_nrf51_1.0.0_API/s130_nrf51_1.0.0_softdevice.hex verify 6 | reset halt 7 | program /home/sstern/nordic/NRF51822-demo/ble_app_own_service/_build/ble_app_own_service.hex verify 8 | reset 9 | 10 | 11 | 12 | program /home/sstern/nordic/s110_nrf51_8.0.0_API/s110_nrf51_8.0.0_softdevice.hex verify 13 | program /home/sstern/nordic/nRF51_SDK_10.0.0_dc26b5e/examples/ble_peripheral/experimental_ble_app_blinky/hex/experimental_ble_app_blinky_s130_pca10028.hex verify reset 14 | program /home/sstern/nordic/nRF51_SDK_10.0.0_dc26b5e/examples/ble_peripheral/ble_app_template/hex/ble_app_template_s130_pca10028.hex -------------------------------------------------------------------------------- /nRF51822/ble_app_max6675/max6675.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | #include 16 | #include "app_error.h" 17 | #include "nrf_drv_spi.h" 18 | #include "nrf_log.h" 19 | #include "nrf_log_ctrl.h" 20 | #include "boards.h" 21 | #include "max6675.h" 22 | 23 | void max6675_init(max6675_config_t const * const max6675_config) { 24 | NRF_LOG_DEBUG("max6675_init %d\n\r",max6675_config->cs_pin); 25 | nrf_gpio_cfg_output(max6675_config->cs_pin); 26 | nrf_gpio_pin_set(max6675_config->cs_pin); 27 | } 28 | 29 | void max6675_prepare(max6675_config_t const * const max6675_config) { 30 | NRF_LOG_DEBUG("max6675_prepare\n\r"); 31 | nrf_gpio_pin_clear(max6675_config->cs_pin); 32 | } 33 | 34 | uint16_t max6675_readcelsius(max6675_config_t const * const max6675_config) { 35 | ret_code_t err_code; 36 | uint8_t outbuffer[2]; 37 | uint16_t temp; 38 | 39 | //NRF_LOG_INFO("max6675_readcelsius\n\r"); 40 | err_code = nrf_drv_spi_transfer(max6675_config->spi_instance,NULL,0,outbuffer,2); 41 | APP_ERROR_CHECK(err_code); 42 | nrf_gpio_pin_set(max6675_config->cs_pin); 43 | 44 | //NRF_LOG_INFO("max6675_readcelsius out=%d %d\n\r",outbuffer[0],outbuffer[1]); 45 | temp = ((uint16_t)outbuffer[0]<<8)|((uint16_t)outbuffer[1]); 46 | temp = temp>>3; 47 | temp = temp*25; 48 | 49 | NRF_LOG_DEBUG("max6675_readcelsius out=%d\n\r",temp); 50 | 51 | return temp; 52 | } 53 | 54 | void max6675_unprepare(max6675_config_t const * const max6675_config) { 55 | NRF_LOG_DEBUG("max6675_prepare\n\r"); 56 | nrf_gpio_pin_set(max6675_config->cs_pin); 57 | } 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /nRF51822/ble_app_max6675/max6675.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | #ifndef MAX6675_H 17 | #define MAX6675_H 18 | /** 19 | * @brief UART header file. 20 | * 21 | * This file contains the defining code for a application using UART. 22 | * 23 | */ 24 | 25 | #define MAX6675_DEFAULT_CONFIG { \ 26 | .miso_pin = SPIM0_MISO_PIN, \ 27 | .sck_pin = SPIM0_SCK_PIN, \ 28 | .cs_pin = SPIM0_SS_PIN, \ 29 | .spi_instance = NULL \ 30 | } 31 | 32 | /**@brief MAX6675 configuration structure.*/ 33 | typedef struct { 34 | uint32_t miso_pin; /* Pin number for MISO input. */ 35 | uint32_t sck_pin; /* Pin number for CLK output. */ 36 | uint32_t cs_pin; /* Pin number for client select/Load output. */ 37 | nrf_drv_spi_t const *spi_instance; /* ptr to SPI instance */ 38 | } max6675_config_t; 39 | 40 | /**@brief Function for initialize max6675. 41 | * 42 | * @param[in] max6675_config Pointer to MAX6675 configuration structure. 43 | */ 44 | void max6675_init(max6675_config_t const * const max6675_config); 45 | 46 | /**@brief Function for prepare reading max6675. 47 | * 48 | * @param[in] max6675_config Pointer to MAX6675 configuration structure. 49 | */ 50 | void max6675_prepare(max6675_config_t const * const max6675_config); 51 | 52 | /**@brief Function for reading max6675 value in 0.25 times degrees celsius. 53 | * 54 | * @param[in] max6675_config Pointer to MAX6675 configuration structure. 55 | * 56 | * @return value in 0.25 times degrees celsius. 57 | */ 58 | uint16_t max6675_readcelsius(max6675_config_t const * const max6675_config); 59 | 60 | 61 | /**@brief Function for prepare reading max6675. 62 | * 63 | * @param[in] max6675_config Pointer to MAX6675 configuration structure. 64 | */ 65 | void max6675_unprepare(max6675_config_t const * const max6675_config); 66 | 67 | #endif // MAX6675_H 68 | -------------------------------------------------------------------------------- /nRF51822/ble_app_mcp3008/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ble_app_mcp3008 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | 26 | 27 | -------------------------------------------------------------------------------- /nRF51822/ble_app_mcp3008/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /nRF51822/ble_app_mcp3008/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF51822 8 | CFLAGS += -DNRF_LOG_USES_UART=1 9 | CFLAGS += -DSOFTDEVICE_PRESENT 10 | CFLAGS += -DS130 11 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 12 | CFLAGS += -DSWI_DISABLE0 13 | CFLAGS += -DNRF_SD_BLE_API_VERSION=2 14 | CFLAGS += -D__HEAP_SIZE=0 15 | ASFLAGS += -g 16 | ASMFLAGS += -DBOARD_CUSTOM 17 | ASMFLAGS += -DNRF51822 18 | ASMFLAGS += -DNRF_LOG_USES_UART=1 19 | ASMFLAGS += -DSOFTDEVICE_PRESENT 20 | ASMFLAGS += -DS130 21 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 22 | ASMFLAGS += -DSWI_DISABLE0 23 | ASMFLAGS += -DNRF_SD_BLE_API_VERSION=2 24 | ASMFLAGS += -D__HEAP_SIZE=0 25 | #LDLIBS += -lc -lgcc -lrdimon 26 | 27 | LDSCRIPT = $(TEMPLATEROOT)/s130_v2_nrf51822_QFAA.ld 28 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s130/headers 29 | 30 | vpath %.c $(SDK_PATH)/components/softdevice/s130/headers 31 | 32 | # object files 33 | 34 | OBJS += system_nrf51.o nrf_log_backend_serial.o nrf_log_frontend.o 35 | OBJS += app_error_weak.o app_error.o app_fifo.o app_util_platform.o nrf_assert.o app_uart_fifo.o 36 | OBJS += app_timer.o 37 | OBJS += nrf_drv_common.o nrf_drv_uart.o nrf_drv_spi.o nrf_drv_clock.o 38 | OBJS += bsp.o main.o fstorage.o fds.o sdk_mapped_flags.o 39 | OBJS += ble_advdata.o ble_advertising.o ble_conn_params.o 40 | OBJS += mcp3008.o ble_mcp3008.o ble_srv_common.o ble_conn_state.o 41 | OBJS += gatt_cache_manager.o gatts_cache_manager.o id_manager.o peer_data.o 42 | OBJS += peer_data_storage.o peer_database.o peer_id.o peer_manager.o 43 | OBJS += pm_buffer.o pm_mutex.o security_dispatcher.o security_manager.o 44 | OBJS += softdevice_handler.o 45 | # include common make file 46 | 47 | include $(TEMPLATEROOT)/Makefile.common 48 | -------------------------------------------------------------------------------- /nRF51822/ble_app_mcp3008/ble_mcp3008.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | /** @file ble_mcp3008.h 17 | * 18 | * @brief Temperature Service module. 19 | * 20 | * @details This module implements the MCP3008 Service with the MCP3008 characteristic. 21 | * During initialization it adds the MCP3008 Service and MCP3008 characteristic 22 | * to the BLE stack database. 23 | * 24 | * If specified, the module will support notification of the MCP3008 characteristic 25 | * through the ble_mcp3008_read() function. 26 | * If an event handler is supplied by the application, the MCP3008 Service will 27 | * generate MCP3008 Service events to the application. 28 | * 29 | * @note The application must propagate BLE stack events to the MCP3008 Service module by calling 30 | * ble_mcp3008_on_ble_evt() from the @ref softdevice_handler callback. 31 | * 32 | */ 33 | 34 | #ifndef BLE_MCP3008_H__ 35 | #define BLE_MCP3008_H__ 36 | 37 | #include 38 | #include 39 | #include "ble.h" 40 | #include "ble_srv_common.h" 41 | #include "app_util.h" 42 | 43 | // using random numbers via https://www.uuidgenerator.net/ 44 | #define BLE_MCP3008_UUID_BASE {0x18, 0x1B, 0xDB, 0x53, 0x32, 0x6C, 0x44, 0x23, \ 45 | 0xBB, 0x89, 0x65, 0x87, 0xAA, 0xEE, 0xEE, 0x07} 46 | #define BLE_MCP3008_UUID_SERVICE 0x3141 47 | #define BLE_MCP3008_UUID_COM_CHAR 0x3142 48 | #define BLE_MCP3008_UUID_VALUE_CHAR 0x3143 49 | 50 | #define BLE_MCP3008_COM_MAX_LEN 6 /* max number of bytes per BLE package */ 51 | #define BLE_MCP3008_VALUE_MAX_LEN sizeof(uint16_t) /* max number of bytes */ 52 | 53 | /**@brief MCP3008 Service event type. */ 54 | typedef enum { 55 | BLE_MCP3008_EVT_NOTIFICATION_ENABLED, /**< MCP3008 value notification enabled event. */ 56 | BLE_MCP3008_EVT_NOTIFICATION_DISABLED, /**< MCP3008 value notification disabled event. */ 57 | BLE_MCP3008_EVT_DISCONNECTED /**< MCP3008 value notification disconnected event. */ 58 | } ble_mcp3008_evt_type_t; 59 | 60 | /**@brief MCP3008 Service event. */ 61 | typedef struct { 62 | ble_mcp3008_evt_type_t evt_type; /**< Type of event. */ 63 | } ble_mcp3008_evt_t; 64 | 65 | // Forward declaration of the ble_mcp3008_t type. 66 | typedef struct ble_mcp3008_s ble_mcp3008_t; 67 | 68 | /**@brief MCP3008 Service event handler type. */ 69 | typedef void (*ble_mcp3008_evt_handler_t) (ble_mcp3008_t * p_mcp3008, ble_mcp3008_evt_t *evt); 70 | 71 | /**@brief MCP3008 Service init structure. This contains all options and data needed for 72 | * initialization of the service.*/ 73 | typedef struct { 74 | ble_mcp3008_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the MCP3008 Service. */ 75 | } ble_mcp3008_init_t; 76 | 77 | typedef enum { 78 | BLE_MCP3008_COM_START, /**< command truncate channel info. */ 79 | BLE_MCP3008_COM_STOP, /**< command truncate channel info. */ 80 | BLE_MCP3008_COM_NOTIFY /**< command truncate channel info. */ 81 | } ble_mcp3008_command_type_t; 82 | 83 | typedef enum { 84 | BLE_MCP3008_START_STOP, /**< command truncate channel info. */ 85 | BLE_MCP3008_START_TIMER, /**< command truncate channel info. */ 86 | BLE_MCP3008_START_PWM, /**< command truncate channel info. */ 87 | BLE_MCP3008_START_SOFTBLINK, /**< command truncate channel info. */ 88 | BLE_MCP3008_START_SERVO 89 | } ble_mcp3008_start_type_t; 90 | 91 | /**@brief MCP3008 Service structure. This contains various status information for the service. */ 92 | struct ble_mcp3008_s { 93 | uint16_t service_handle; /**< Handle of MCP3008 Service (as provided by the BLE stack). */ 94 | ble_gatts_char_handles_t com_char_handles; /**< Handles related to the adding characteristic. */ 95 | ble_gatts_char_handles_t value_char_handles; /**< Handles related to the notifying values characteristic. */ 96 | uint16_t report_ref_handle; /**< Handle of the Report Reference descriptor. */ 97 | uint8_t uuid_type; /**< UUID type for the MCP3008 Service. */ 98 | uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack). BLE_CONN_HANDLE_INVALID if not in a connection. */ 99 | ble_mcp3008_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the MCP3008 Service. */ 100 | uint16_t last_temp; /**< Temperature in 0.25 degrees celsius. */ 101 | uint8_t running; /**< Temperature in 0.25 degrees celsius. */ 102 | }; 103 | 104 | /**@brief Function for initializing the MCP3008 Service. 105 | * 106 | * @param[out] p_mcp3008 MCP3008 Service structure. This structure will have to be supplied by 107 | * the application. It will be initialized by this function, and will later 108 | * be used to identify this particular service instance. 109 | * @param[in] p_mcp3008_init Information needed to initialize the service. 110 | * 111 | * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. 112 | */ 113 | uint32_t ble_mcp3008_init(ble_mcp3008_t * p_mcp3008, const ble_mcp3008_init_t * p_mcp3008_init); 114 | 115 | /**@brief Function for handling the Application's BLE Stack events. 116 | * 117 | * @details Handles all events from the BLE stack of interest to the MCP3008 Service. 118 | * 119 | * @param[in] p_mcp3008 MCP3008 Service structure. 120 | * @param[in] p_ble_evt Event received from the BLE stack. 121 | */ 122 | void ble_mcp3008_on_ble_evt(ble_mcp3008_t * p_mcp3008, ble_evt_t * p_ble_evt); 123 | 124 | /**@brief Function for initializing the MCP3008 Service. 125 | * 126 | * @param[in] p_mcp3008 MCP3008 Service structure. 127 | * @param[in] temp Temperature in 0.25 degrees celsius. 128 | * 129 | * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. 130 | */ 131 | uint32_t ble_mcp3008_temp_update(ble_mcp3008_t * p_mcp3008, uint16_t temp); 132 | 133 | #endif // BLE_MCP3008_H__ 134 | 135 | /** @} */ 136 | -------------------------------------------------------------------------------- /nRF51822/ble_app_mcp3008/mcp3008.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | #include 16 | #include "app_error.h" 17 | #include "nrf_drv_spi.h" 18 | #include "nrf_log.h" 19 | #include "nrf_log_ctrl.h" 20 | #include "boards.h" 21 | #include "mcp3008.h" 22 | 23 | void mcp3008_init(mcp3008_config_t const * const mcp3008_config) { 24 | NRF_LOG_DEBUG("mcp3008_init %d\n\r",mcp3008_config->cs_pin); 25 | nrf_gpio_cfg_output(mcp3008_config->cs_pin); 26 | nrf_gpio_pin_set(mcp3008_config->cs_pin); 27 | } 28 | 29 | void mcp3008_prepare(mcp3008_config_t const * const mcp3008_config) { 30 | NRF_LOG_DEBUG("mcp3008_prepare\n\r"); 31 | nrf_gpio_pin_clear(mcp3008_config->cs_pin); 32 | } 33 | 34 | uint16_t mcp3008_readanalog(mcp3008_config_t const * const mcp3008_config,uint8_t adcnum) { 35 | ret_code_t err_code; 36 | uint8_t inbuffer[1]; 37 | uint8_t outbuffer[2]; 38 | uint16_t adcout; 39 | 40 | //NRF_LOG_INFO("mcp3008_readanalog\n\r"); 41 | inbuffer[1]=0x08|adcnum; // single-ended 42 | inbuffer[1]=inbuffer[1]<<4; 43 | 44 | err_code = nrf_drv_spi_transfer(mcp3008_config->spi_instance,inbuffer,1,outbuffer,2); 45 | APP_ERROR_CHECK(err_code); 46 | nrf_gpio_pin_set(mcp3008_config->cs_pin); 47 | 48 | //NRF_LOG_INFO("mcp3008_readanalog out=%d %d\n\r",outbuffer[0],outbuffer[1]); 49 | adcout = ((uint16_t)outbuffer[0]<<8)|((uint16_t)outbuffer[1]); 50 | 51 | NRF_LOG_DEBUG("mcp3008_readanalog out=%d\n\r",adcout); 52 | 53 | return adcout; 54 | } 55 | 56 | void mcp3008_unprepare(mcp3008_config_t const * const mcp3008_config) { 57 | NRF_LOG_DEBUG("mcp3008_prepare\n\r"); 58 | nrf_gpio_pin_set(mcp3008_config->cs_pin); 59 | } 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /nRF51822/ble_app_mcp3008/mcp3008.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | #ifndef MCP3008_H 17 | #define MCP3008_H 18 | /** 19 | * @brief UART header file. 20 | * 21 | * This file contains the defining code for a application using UART. 22 | * 23 | */ 24 | 25 | #define MCP3008_DEFAULT_CONFIG { \ 26 | .miso_pin = SPIM0_MISO_PIN, \ 27 | .sck_pin = SPIM0_SCK_PIN, \ 28 | .cs_pin = SPIM0_SS_PIN, \ 29 | .spi_instance = NULL \ 30 | } 31 | 32 | /**@brief MCP3008 configuration structure.*/ 33 | typedef struct { 34 | uint32_t miso_pin; /* Pin number for MISO input. */ 35 | uint32_t sck_pin; /* Pin number for CLK output. */ 36 | uint32_t cs_pin; /* Pin number for client select/Load output. */ 37 | nrf_drv_spi_t const *spi_instance; /* ptr to SPI instance */ 38 | } mcp3008_config_t; 39 | 40 | /**@brief Function for initialize mcp3008. 41 | * 42 | * @param[in] mcp3008_config Pointer to MCP3008 configuration structure. 43 | */ 44 | void mcp3008_init(mcp3008_config_t const * const mcp3008_config); 45 | 46 | /**@brief Function for prepare reading mcp3008. 47 | * 48 | * @param[in] mcp3008_config Pointer to MCP3008 configuration structure. 49 | */ 50 | void mcp3008_prepare(mcp3008_config_t const * const mcp3008_config); 51 | 52 | /**@brief Function for reading mcp3008 value in 0.25 times degrees celsius. 53 | * 54 | * @param[in] mcp3008_config Pointer to MCP3008 configuration structure. 55 | * @param[in] adcnum MCP3008 chip has 8 adc's (0 thru 7) 56 | * 57 | * @return value in 0.25 times degrees celsius. 58 | */ 59 | uint16_t mcp3008_readanalog(mcp3008_config_t const * const mcp3008_config,uint8_t adcnum); 60 | 61 | 62 | /**@brief Function for prepare reading mcp3008. 63 | * 64 | * @param[in] mcp3008_config Pointer to MCP3008 configuration structure. 65 | */ 66 | void mcp3008_unprepare(mcp3008_config_t const * const mcp3008_config); 67 | 68 | #endif // MCP3008_H 69 | -------------------------------------------------------------------------------- /nRF51822/ble_app_si7021/.gitignore: -------------------------------------------------------------------------------- 1 | flash.txt 2 | -------------------------------------------------------------------------------- /nRF51822/ble_app_si7021/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ble_app_si7021 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | 26 | 27 | -------------------------------------------------------------------------------- /nRF51822/ble_app_si7021/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /nRF51822/ble_app_si7021/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF51822 8 | CFLAGS += -DNRF_LOG_USES_UART=1 9 | CFLAGS += -DSOFTDEVICE_PRESENT 10 | CFLAGS += -DS130 11 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 12 | CFLAGS += -DSWI_DISABLE0 13 | CFLAGS += -DNRF_SD_BLE_API_VERSION=2 14 | CFLAGS += -D__HEAP_SIZE=0 15 | ASFLAGS += -g 16 | ASMFLAGS += -DBOARD_CUSTOM 17 | ASMFLAGS += -DNRF51822 18 | ASMFLAGS += -DNRF_LOG_USES_UART=1 19 | ASMFLAGS += -DSOFTDEVICE_PRESENT 20 | ASMFLAGS += -DS130 21 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 22 | ASMFLAGS += -DSWI_DISABLE0 23 | ASMFLAGS += -DNRF_SD_BLE_API_VERSION=2 24 | ASMFLAGS += -D__HEAP_SIZE=0 25 | #LDLIBS += -lc -lgcc -lrdimon 26 | 27 | LDSCRIPT = $(TEMPLATEROOT)/s130_v2_nrf51822_QFAA.ld 28 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s130/headers 29 | 30 | vpath %.c $(SDK_PATH)/components/softdevice/s130/headers 31 | 32 | # object files 33 | 34 | OBJS += system_nrf51.o nrf_log_backend_serial.o nrf_log_frontend.o 35 | OBJS += app_error_weak.o app_error.o app_fifo.o app_util_platform.o nrf_assert.o app_uart_fifo.o 36 | OBJS += app_timer.o 37 | OBJS += nrf_drv_common.o nrf_drv_uart.o nrf_drv_twi.o nrf_drv_clock.o 38 | OBJS += bsp.o main.o fstorage.o fds.o sdk_mapped_flags.o 39 | OBJS += ble_advdata.o ble_advertising.o ble_conn_params.o 40 | OBJS += ble_si7021.o ble_srv_common.o ble_conn_state.o 41 | OBJS += gatt_cache_manager.o gatts_cache_manager.o id_manager.o peer_data.o 42 | OBJS += peer_data_storage.o peer_database.o peer_id.o peer_manager.o 43 | OBJS += pm_buffer.o pm_mutex.o security_dispatcher.o security_manager.o 44 | OBJS += softdevice_handler.o 45 | # include common make file 46 | 47 | include $(TEMPLATEROOT)/Makefile.common 48 | -------------------------------------------------------------------------------- /nRF51822/ble_app_si7021/ble_si7021.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | /** @file ble_si7021.h 17 | * 18 | * @brief Relative Humidity and Temperature Service module. 19 | * 20 | * @details This module implements the si7021 Service with the si7021 characteristic. 21 | * During initialization it adds the si7021 Service and si7021 characteristic 22 | * to the BLE stack database. 23 | * 24 | * If specified, the module will support notification of the si7021 characteristic 25 | * through the ble_si7021_read() function. 26 | * If an event handler is supplied by the application, the si7021 Service will 27 | * generate si7021 Service events to the application. 28 | * 29 | * @note The application must propagate BLE stack events to the si7021 Service module by calling 30 | * ble_si7021_on_ble_evt() from the @ref softdevice_handler callback. 31 | * 32 | */ 33 | 34 | #ifndef BLE_si7021_H__ 35 | #define BLE_si7021_H__ 36 | 37 | #include 38 | #include 39 | #include "ble.h" 40 | #include "ble_srv_common.h" 41 | #include "app_util.h" 42 | 43 | // using use linux tool uuidgen or random numbers via https://www.uuidgenerator.net/ 44 | #define BLE_si7021_UUID_BASE {0xa8, 0xb4, 0xc9, 0x4a, 0xad, 0x6c, 0x11, 0xe6, \ 45 | 0x9a, 0xd8, 0x5d, 0x07, 0xa0, 0x9d, 0x94, 0x6b} 46 | 47 | 48 | #define BLE_si7021_UUID_SERVICE 0x3144 49 | #define BLE_si7021_UUID_COM_CHAR 0x3145 50 | #define BLE_si7021_UUID_VALUE_CHAR 0x3146 51 | 52 | #define BLE_si7021_COM_MAX_LEN 2 /* max number of bytes */ 53 | #define BLE_si7021_VALUE_MAX_LEN 4 /* max number of bytes */ 54 | 55 | /**@brief si7021 Service event type. */ 56 | typedef enum { 57 | BLE_si7021_EVT_NOTIFICATION_ENABLED, /**< si7021 value notification enabled event. */ 58 | BLE_si7021_EVT_NOTIFICATION_DISABLED, /**< si7021 value notification disabled event. */ 59 | BLE_si7021_EVT_INTERVAL_CHANGE, /**< si7021 interval change event. */ 60 | BLE_si7021_EVT_DISCONNECTED /**< si7021 value notification disconnected event. */ 61 | } ble_si7021_evt_type_t; 62 | 63 | /**@brief si7021 Service event. */ 64 | typedef struct { 65 | ble_si7021_evt_type_t evt_type; /**< Type of event. */ 66 | } ble_si7021_evt_t; 67 | 68 | // Forward declaration of the ble_si7021_t type. 69 | typedef struct ble_si7021_s ble_si7021_t; 70 | 71 | /**@brief si7021 Service event handler type. */ 72 | typedef void (*ble_si7021_evt_handler_t) (ble_si7021_t * p_si7021, ble_si7021_evt_t *evt); 73 | 74 | /**@brief si7021 Service init structure. This contains all options and data needed for 75 | * initialization of the service.*/ 76 | typedef struct { 77 | ble_si7021_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the si7021 Service. */ 78 | } ble_si7021_init_t; 79 | 80 | typedef enum { 81 | BLE_si7021_COM_START, /**< command truncate channel info. */ 82 | BLE_si7021_COM_STOP, /**< command truncate channel info. */ 83 | BLE_si7021_COM_NOTIFY /**< command truncate channel info. */ 84 | } ble_si7021_command_type_t; 85 | 86 | /**@brief si7021 Service structure. This contains various status information for the service. */ 87 | struct ble_si7021_s { 88 | uint16_t service_handle; /**< Handle of si7021 Service (as provided by the BLE stack). */ 89 | ble_gatts_char_handles_t com_char_handles; /**< Handles related to the adding characteristic. */ 90 | ble_gatts_char_handles_t value_char_handles; /**< Handles related to the notifying values characteristic. */ 91 | uint16_t report_ref_handle; /**< Handle of the Report Reference descriptor. */ 92 | uint8_t uuid_type; /**< UUID type for the si7021 Service. */ 93 | uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack). BLE_CONN_HANDLE_INVALID if not in a connection. */ 94 | ble_si7021_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the si7021 Service. */ 95 | uint16_t last_humraw; /**< Relative Humidity Raw 16-Bit. */ 96 | uint16_t last_tempraw; /**< Temperature Raw 16-Bit. */ 97 | uint8_t running; /**< running indicator. */ 98 | uint16_t interval; /**< Sensor mesurement intervall. */ 99 | }; 100 | 101 | /**@brief Function for initializing the si7021 Service. 102 | * 103 | * @param[out] p_si7021 si7021 Service structure. This structure will have to be supplied by 104 | * the application. It will be initialized by this function, and will later 105 | * be used to identify this particular service instance. 106 | * @param[in] p_si7021_init Information needed to initialize the service. 107 | * 108 | * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. 109 | */ 110 | uint32_t ble_si7021_init(ble_si7021_t * p_si7021, const ble_si7021_init_t * p_si7021_init); 111 | 112 | /**@brief Function for handling the Application's BLE Stack events. 113 | * 114 | * @details Handles all events from the BLE stack of interest to the si7021 Service. 115 | * 116 | * @param[in] p_si7021 si7021 Service structure. 117 | * @param[in] p_ble_evt Event received from the BLE stack. 118 | */ 119 | void ble_si7021_on_ble_evt(ble_si7021_t * p_si7021, ble_evt_t * p_ble_evt); 120 | 121 | /**@brief Function for initializing the si7021 Service. 122 | * 123 | * @param[in] p_si7021 si7021 Service structure. 124 | * @param[in] hum Relative Humidity Raw 16-Bit. 125 | * @param[in] temp Temperature Raw 16-Bit. 126 | * 127 | * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. 128 | */ 129 | uint32_t ble_si7021_sensor_update(ble_si7021_t * p_si7021, uint16_t hum, uint16_t temp); 130 | 131 | #endif // BLE_si7021_H__ 132 | 133 | /** @} */ 134 | -------------------------------------------------------------------------------- /nRF51822/ble_app_si7021/custom_board.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | #ifndef BLE_TEST_BOARD_H 13 | #define BLE_TEST_BOARD_H 14 | 15 | // LEDs definitions for PCA10028 16 | #define LEDS_NUMBER 5 17 | 18 | #define LED_START 18 19 | #define LED_1 18 20 | #define LED_2 19 21 | #define LED_3 20 22 | #define LED_4 21 23 | #define LED_5 22 24 | #define LED_STOP 22 25 | 26 | #define LEDS_LIST { LED_1, LED_2, LED_3, LED_4, LED_5 } 27 | 28 | #define BSP_LED_0 LED_1 29 | #define BSP_LED_1 LED_2 30 | #define BSP_LED_2 LED_3 31 | #define BSP_LED_3 LED_4 32 | #define BSP_LED_4 LED_5 33 | 34 | #define BSP_LED_0_MASK (1< CPTX 63 | #define TX_PIN_NUMBER 2 // -> CPRX 64 | #define CTS_PIN_NUMBER 7 // -> CPRTS 65 | #define RTS_PIN_NUMBER 8 // -> CPCTS 66 | #define HWFC false 67 | #define UART0_CONFIG_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200 68 | 69 | #define SPIS_MISO_PIN 28 // SPI MISO signal. 70 | #define SPIS_CSN_PIN 12 // SPI CSN signal. 71 | #define SPIS_MOSI_PIN 25 // SPI MOSI signal. 72 | #define SPIS_SCK_PIN 29 // SPI SCK signal. 73 | 74 | #define SPIM0_SCK_PIN 3 /**< SPI clock GPIO pin number. */ 75 | #define SPIM0_MOSI_PIN 5 /**< SPI Master Out Slave In GPIO pin number. */ 76 | #define SPIM0_MISO_PIN 4 /**< SPI Master In Slave Out GPIO pin number. */ 77 | #define SPIM0_SS_PIN 9 /**< SPI Slave Select GPIO pin number. */ 78 | 79 | #define SPIM1_SCK_PIN 15 /**< SPI clock GPIO pin number. */ 80 | #define SPIM1_MOSI_PIN 12 /**< SPI Master Out Slave In GPIO pin number. */ 81 | #define SPIM1_MISO_PIN 14 /**< SPI Master In Slave Out GPIO pin number. */ 82 | #define SPIM1_SS_PIN 13 /**< SPI Slave Select GPIO pin number. */ 83 | 84 | // serialization APPLICATION board 85 | #define SER_CONN_CHIP_RESET_PIN 30 // Pin used to reset connectivity chip 86 | 87 | #define SER_APP_RX_PIN RX_PIN_NUMBER // UART RX pin number. 88 | #define SER_APP_TX_PIN TX_PIN_NUMBER // UART TX pin number. 89 | #define SER_APP_CTS_PIN CTS_PIN_NUMBER // UART Clear To Send pin number. 90 | #define SER_APP_RTS_PIN RTS_PIN_NUMBER // UART Request To Send pin number. 91 | 92 | #define SER_APP_SPIM0_SCK_PIN 29 // SPI clock GPIO pin number. 93 | #define SER_APP_SPIM0_MOSI_PIN 25 // SPI Master Out Slave In GPIO pin number 94 | #define SER_APP_SPIM0_MISO_PIN 28 // SPI Master In Slave Out GPIO pin number 95 | #define SER_APP_SPIM0_SS_PIN 12 // SPI Slave Select GPIO pin number 96 | #define SER_APP_SPIM0_RDY_PIN 14 // SPI READY GPIO pin number 97 | #define SER_APP_SPIM0_REQ_PIN 13 // SPI REQUEST GPIO pin number 98 | 99 | // serialization CONNECTIVITY board 100 | #define SER_CON_RX_PIN RX_PIN_NUMBER // UART RX pin number. 101 | #define SER_CON_TX_PIN TX_PIN_NUMBER // UART TX pin number. 102 | #define SER_CON_CTS_PIN CTS_PIN_NUMBER // UART Clear To Send pin number. Not used if HWFC is set to false. 103 | #define SER_CON_RTS_PIN RTS_PIN_NUMBER // UART Request To Send pin number. Not used if HWFC is set to false. 104 | 105 | 106 | #define SER_CON_SPIS_SCK_PIN 29 // SPI SCK signal. 107 | #define SER_CON_SPIS_MOSI_PIN 25 // SPI MOSI signal. 108 | #define SER_CON_SPIS_MISO_PIN 28 // SPI MISO signal. 109 | #define SER_CON_SPIS_CSN_PIN 12 // SPI CSN signal. 110 | #define SER_CON_SPIS_RDY_PIN 14 // SPI READY GPIO pin number. 111 | #define SER_CON_SPIS_REQ_PIN 13 // SPI REQUEST GPIO pin number. 112 | 113 | // Arduino board mappings 114 | #define ARDUINO_SCL_PIN 3 // SCL signal pin 115 | #define ARDUINO_SDA_PIN 4 // SDA signal pin 116 | #define ARDUINO_AREF_PIN 0 // Aref pin 117 | #define ARDUINO_13_PIN 29 // Digital pin 13 118 | #define ARDUINO_12_PIN 28 // Digital pin 12 119 | #define ARDUINO_11_PIN 25 // Digital pin 11 120 | #define ARDUINO_10_PIN 24 // Digital pin 10 121 | #define ARDUINO_9_PIN 23 // Digital pin 9 122 | #define ARDUINO_8_PIN 20 // Digital pin 8 123 | 124 | #define ARDUINO_7_PIN 19 // Digital pin 7 125 | #define ARDUINO_6_PIN 18 // Digital pin 6 126 | #define ARDUINO_5_PIN 17 // Digital pin 5 127 | #define ARDUINO_4_PIN 16 // Digital pin 4 128 | #define ARDUINO_3_PIN 15 // Digital pin 3 129 | #define ARDUINO_2_PIN 14 // Digital pin 2 130 | #define ARDUINO_1_PIN 13 // Digital pin 1 131 | #define ARDUINO_0_PIN 12 // Digital pin 0 132 | 133 | #define ARDUINO_A0_PIN 1 // Analog channel 0 134 | #define ARDUINO_A1_PIN 2 // Analog channel 1 135 | #define ARDUINO_A2_PIN 3 // Analog channel 2 136 | #define ARDUINO_A3_PIN 4 // Analog channel 3 137 | #define ARDUINO_A4_PIN 5 // Analog channel 4 138 | #define ARDUINO_A5_PIN 6 // Analog channel 5 139 | 140 | // Low frequency clock source to be used by the SoftDevice 141 | /* 142 | #define NRF_CLOCK_LFCLKSRC NRF_CLOCK_LFCLKSRC_XTAL_20_PPM 143 | */ 144 | #define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_SYNTH, \ 145 | .rc_ctiv = 0, \ 146 | .rc_temp_ctiv = 0, \ 147 | .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} 148 | 149 | #endif // BLE_TEST_BOARD_H 150 | -------------------------------------------------------------------------------- /nRF51822/ble_app_si7021/flash.txt: -------------------------------------------------------------------------------- 1 | Hallo 2 | -------------------------------------------------------------------------------- /nRF51822/blinky/.gitignore: -------------------------------------------------------------------------------- 1 | .cproject 2 | .project 3 | .settings 4 | -------------------------------------------------------------------------------- /nRF51822/blinky/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | ASFLAGS += -g 7 | 8 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf51822_QFAA.ld 9 | 10 | # object files 11 | 12 | OBJS = system_nrf51.o blinky.o 13 | OBJS += nrf_delay.o 14 | 15 | # include common make file 16 | 17 | include $(TEMPLATEROOT)/Makefile.common 18 | -------------------------------------------------------------------------------- /nRF51822/blinky/blinky.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file blinky.c (changed by pcbreflux) 14 | * @brief Blinky Example Application main file. 15 | * 16 | */ 17 | #include 18 | #include "nrf_delay.h" 19 | #include "nrf_gpio.h" 20 | 21 | const uint32_t led_pin1 = 19; 22 | 23 | /** 24 | * @brief Function for application main entry. 25 | */ 26 | int main(void) { 27 | 28 | // setup 29 | // Configure LED-pin as outputs and clear. 30 | nrf_gpio_cfg_output(led_pin1); 31 | nrf_gpio_pin_clear(led_pin1); 32 | 33 | // loop 34 | // Toggle LED. 35 | while (true) { 36 | nrf_gpio_pin_toggle(led_pin1); 37 | nrf_delay_ms(500); 38 | } 39 | } 40 | 41 | 42 | /** @} */ 43 | -------------------------------------------------------------------------------- /nRF51822/blinky/flash.txt: -------------------------------------------------------------------------------- 1 | openocd -d3 -f ../openocd.cfg 2 | telnet 127.0.0.1 4444 3 | reset halt 4 | nrf51 mass_erase 5 | ##flash banks 6 | halt 7 | program /home/pcbreflux/nordic/nordic.git/nRF51822/blinky/_build/blinky.hex verify 8 | reset 9 | -------------------------------------------------------------------------------- /nRF51822/custom_board.h: -------------------------------------------------------------------------------- 1 | ble_test_board.h -------------------------------------------------------------------------------- /nRF51822/dfu_app/Makefile: -------------------------------------------------------------------------------- 1 | Makefile.S130 -------------------------------------------------------------------------------- /nRF51822/dfu_app/Makefile.S130: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF51822 8 | CFLAGS += -DNRF_LOG_USES_UART=1 9 | CFLAGS += -DSOFTDEVICE_PRESENT 10 | CFLAGS += -DS130 11 | CFLAGS += -DNRF_SD_BLE_API_VERSION=2 12 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 13 | CFLAGS += -DSWI_DISABLE0 14 | ASMFLAGS += -g 15 | ASMFLAGS += -DBOARD_CUSTOM 16 | ASMFLAGS += -DNRF51822 17 | ASMFLAGS += -DNRF_LOG_USES_UART=1 18 | ASMFLAGS += -DSOFTDEVICE_PRESENT 19 | ASMFLAGS += -DS130 20 | ASMFLAGS += -DNRF_SD_BLE_API_VERSION=2 21 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 22 | ASMFLAGS += -DSWI_DISABLE0 23 | 24 | LDSCRIPT = $(TEMPLATEROOT)/s130_v2_nrf51822_QFAC.ld 25 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s130/headers 26 | 27 | vpath %.c $(SDK_PATH)/components/softdevice/s130/headers 28 | 29 | # object files 30 | 31 | OBJS = nrf_log_backend_serial.o nrf_log_frontend.o 32 | OBJS += app_button.o app_error.o app_error_weak.o app_fifo.o app_util_platform.o 33 | OBJS += hardfault_implementation.o nrf_assert.o 34 | OBJS += nrf_drv_clock.o nrf_drv_common.o nrf_drv_rtc.o nrf_drv_gpiote.o nrf_drv_uart.o 35 | OBJS += bsp.o main.o 36 | OBJS += ble_advdata.o ble_conn_params.o ble_srv_common.o 37 | OBJS += system_nrf51.o softdevice_handler.o 38 | # include common make file 39 | 40 | include $(TEMPLATEROOT)/Makefile.common 41 | -------------------------------------------------------------------------------- /nRF51822/dfu_app/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | /** @file main.c (changed by pcbreflux) 17 | * @brief dfu Example Application main file. 18 | * 19 | */ 20 | #include 21 | #include "nrf_gpio.h" 22 | #include "nrf_log.h" 23 | #include "nrf_log_ctrl.h" 24 | #include "app_error.h" 25 | #include "app_error_weak.h" 26 | #include "nordic_common.h" 27 | #include "softdevice_handler.h" 28 | #include "nrf_drv_clock.h" 29 | #include "nrf_drv_rtc.h" 30 | #include "bsp.h" 31 | 32 | // see nrf_drv_config.h for defining RTC1 33 | #define RTC1_CC_VALUE 8 // 125ms*8*1=1s 34 | // Softdevice S110, S120, S130 blocks RTC0 35 | const nrf_drv_rtc_t rtc1 = NRF_DRV_RTC_INSTANCE(1); /**< Declaring an instance of nrf_drv_rtc for RTC1. */ 36 | 37 | static uint32_t tick_pos = 0; 38 | 39 | static void rtc1_handler(nrf_drv_rtc_int_type_t int_type) { 40 | // uint32_t err_code; 41 | 42 | if (int_type == NRF_DRV_RTC_INT_COMPARE0) { // Interrupt from COMPARE0 event. 43 | NRF_LOG_INFO("test app main loop %d\r\n",tick_pos); 44 | tick_pos++; 45 | nrf_drv_rtc_counter_clear(&rtc1); 46 | nrf_drv_rtc_int_enable(&rtc1, RTC_CHANNEL_INT_MASK(0)); 47 | } 48 | } 49 | 50 | /** @brief Function initialization and configuration of RTC driver instance. 51 | */ 52 | static void rtc_config(void) { 53 | uint32_t err_code; 54 | 55 | //Initialize RTC instance 56 | err_code = nrf_drv_rtc_init(&rtc1, NULL, rtc1_handler); 57 | APP_ERROR_CHECK(err_code); 58 | 59 | //Disable tick event & interrupt 60 | nrf_drv_rtc_tick_enable(&rtc1,false); 61 | 62 | //Set compare channel 0 to trigger interrupt after RTC1_CC_VALUE*125ms 63 | err_code = nrf_drv_rtc_cc_set(&rtc1,0,RTC1_CC_VALUE,true); 64 | APP_ERROR_CHECK(err_code); 65 | 66 | //Power on RTC instance 67 | nrf_drv_rtc_enable(&rtc1); 68 | } 69 | 70 | /**@brief Function for initializing the BLE stack. 71 | * 72 | * @details Initializes the SoftDevice and the BLE event interrupt. 73 | */ 74 | static void ble_stack_init(void) 75 | { 76 | uint32_t err_code; 77 | 78 | nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC; 79 | 80 | // Initialize the SoftDevice handler module. 81 | SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL); 82 | 83 | ble_enable_params_t ble_enable_params; 84 | err_code = softdevice_enable_get_default_config(0,0,&ble_enable_params); 85 | APP_ERROR_CHECK(err_code); 86 | 87 | //Check the ram settings against the used number of links 88 | CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT); 89 | 90 | // Enable BLE stack. 91 | err_code = softdevice_enable(&ble_enable_params); 92 | APP_ERROR_CHECK(err_code); 93 | } 94 | 95 | /**@brief Function for doing power management. 96 | */ 97 | static void power_manage(void) 98 | { 99 | uint32_t err_code = sd_app_evt_wait(); 100 | APP_ERROR_CHECK(err_code); 101 | } 102 | 103 | /** 104 | * @brief Function for application main entry. 105 | */ 106 | int main(void) { 107 | APP_ERROR_CHECK(NRF_LOG_INIT(NULL)); 108 | 109 | NRF_LOG_INFO("test app start\r\n"); 110 | 111 | // Enable BLE stack. 112 | ble_stack_init(); 113 | rtc_config(); 114 | 115 | while (true) { 116 | power_manage(); 117 | } 118 | } 119 | 120 | 121 | /** @} */ 122 | -------------------------------------------------------------------------------- /nRF51822/dfu_secure/Makefile: -------------------------------------------------------------------------------- 1 | Makefile.S130 -------------------------------------------------------------------------------- /nRF51822/dfu_secure/Makefile.S130: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -DuECC_ENABLE_VLI_API 6 | CFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 7 | CFLAGS += -DuECC_SQUARE_FUNC=1 8 | CFLAGS += -DuECC_SUPPORTS_secp256r1=1 9 | CFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 10 | CFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 11 | CFLAGS += -O0 -g 12 | CFLAGS += -DBOARD_CUSTOM 13 | CFLAGS += -DNRF51822 14 | CFLAGS += -DNRF_LOG_USES_UART=1 15 | CFLAGS += -DSOFTDEVICE_PRESENT 16 | CFLAGS += -DNRF_DFU_SETTINGS_VERSION=1 17 | CFLAGS += -D__HEAP_SIZE=0 18 | CFLAGS += -DSVC_INTERFACE_CALL_AS_NORMAL_FUNCTION 19 | CFLAGS += -DS130 20 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 21 | CFLAGS += -DSWI_DISABLE0 22 | CFLAGS += -DNRF_SD_BLE_API_VERSION=2 23 | CFLAGS += -DNRF_DFU_DEBUG_VERSION 24 | CFLAGS += -Os -g3 25 | #CFLAGS += -Os -flto 26 | ASMFLAGS += -DuECC_ENABLE_VLI_API 27 | ASMFLAGS += -DuECC_VLI_NATIVE_LITTLE_ENDIAN=1 28 | ASMFLAGS += -DuECC_SQUARE_FUNC=1 29 | ASMFLAGS += -DuECC_SUPPORTS_secp256r1=1 30 | ASMFLAGS += -DuECC_SUPPORT_COMPRESSED_POINT=0 31 | ASMFLAGS += -DuECC_OPTIMIZATION_LEVEL=3 32 | ASFLAGS += -g 33 | ASMFLAGS += -DBOARD_CUSTOM 34 | ASMFLAGS += -DNRF51822 35 | ASMFLAGS += -DNRF_LOG_USES_UART=1 36 | ASMFLAGS += -DSWI_DISABLE0 37 | ASMFLAGS += -DSOFTDEVICE_PRESENT 38 | ASMFLAGS += -DNRF51 39 | ASMFLAGS += -DNRF_DFU_SETTINGS_VERSION=1 40 | ASMFLAGS += -D__HEAP_SIZE=0 41 | ASMFLAGS += -DSVC_INTERFACE_CALL_AS_NORMAL_FUNCTION 42 | ASMFLAGS += -DS130 43 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 44 | ASMFLAGS += -DNRF_SD_BLE_API_VERSION=2 45 | ASMFLAGS += -DNRF_DFU_DEBUG_VERSION 46 | 47 | LDSCRIPT = secure_dfu_gcc_nrf51_QFAC_debug.ld 48 | 49 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s130/headers 50 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s130/headers/nrf51 51 | INC_PATHS += -I$(TEMPLATEROOT)/micro-ecc 52 | 53 | vpath %.c $(SDK_PATH)/components/softdevice/s130/headers 54 | vpath %.c $(SDK_PATH)/components/softdevice/s130/headers/nrf51 55 | vpath %.c $(TEMPLATEROOT)/micro-ecc 56 | 57 | # object files 58 | 59 | OBJS = app_error_weak.o app_fifo.o app_scheduler.o app_timer.o app_timer_appsh.o app_util_platform.o 60 | OBJS += crc32.o ecc.o fstorage.o hci_mem_pool.o nrf_assert.o nrf_crypto.o sha256.o app_uart_fifo.o nrf_drv_common.o nrf_drv_uart.o 61 | OBJS += nrf_drv_rng.o nrf_nvmc.o nrf_ble_dfu.o 62 | OBJS += nrf_log_backend_serial.o nrf_log_frontend.o 63 | OBJS += dfu-cc.pb.o dfu_public_key.o dfu_req_handling.o main.o 64 | OBJS += ble_advdata.o ble_conn_params.o ble_srv_common.o pb_common.o pb_decode.o 65 | OBJS += system_nrf51.o softdevice_handler.o softdevice_handler_appsh.o nrf_bootloader.o 66 | OBJS += nrf_bootloader_app_start.o nrf_bootloader_info.o nrf_dfu.o nrf_dfu_flash.o 67 | OBJS += nrf_dfu_mbr.o nrf_dfu_settings.o nrf_dfu_transport.o nrf_dfu_utils.o uECC.o 68 | 69 | # include common make file 70 | 71 | include $(TEMPLATEROOT)/Makefile.common 72 | -------------------------------------------------------------------------------- /nRF51822/dfu_secure/secure_dfu_gcc_nrf51_QFAC_debug.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | /** Flash start address for the bootloader. This setting will also be stored in UICR to allow the 9 | * MBR to init the bootloader when starting the system. This value must correspond to 10 | * BOOTLOADER_REGION_START found in dfu_types.h. The system is prevented from starting up if 11 | * those values do not match. The check is performed in main.c, see 12 | * APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START); 13 | */ 14 | FLASH (rx) : ORIGIN = 0x35C00, LENGTH = 0xA000 15 | 16 | /** RAM Region for bootloader. This setting is suitable when used with s110, s120, s130, s310. */ 17 | RAM (rwx) : ORIGIN = 0x200025E0, LENGTH = 0x5A20 18 | 19 | /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information 20 | * from application to bootloader when using buttonluss DFU OTA. 21 | */ 22 | NOINIT (rwx) : ORIGIN = 0x20007F80, LENGTH = 0x80 23 | 24 | /** Location of bootloader setting in at the last flash page. */ 25 | BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0003FC00, LENGTH = 0x0400 26 | 27 | /** Location in UICR where bootloader start address is stored. */ 28 | UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04 29 | } 30 | 31 | SECTIONS 32 | { 33 | /* Ensures the bootloader settings are placed at the last flash page. */ 34 | .bootloaderSettings(NOLOAD) : 35 | { 36 | 37 | } > BOOTLOADER_SETTINGS 38 | 39 | /* Ensures the Bootloader start address in flash is written to UICR when flashing the image. */ 40 | .uicrBootStartAddress : 41 | { 42 | KEEP(*(.uicrBootStartAddress)) 43 | } > UICR_BOOTLOADER 44 | 45 | /* No init RAM section in bootloader. Used for bond information exchange. */ 46 | .noinit(NOLOAD) : 47 | { 48 | 49 | } > NOINIT 50 | /* other placements follow here... */ 51 | } 52 | 53 | SECTIONS 54 | { 55 | . = ALIGN(4); 56 | .fs_data : 57 | { 58 | PROVIDE(__start_fs_data = .); 59 | KEEP(*(.fs_data)) 60 | PROVIDE(__stop_fs_data = .); 61 | } > RAM 62 | 63 | . = ALIGN(4); 64 | .svc_data : 65 | { 66 | PROVIDE(__start_svc_data = .); 67 | KEEP(*(.svc_data)) 68 | PROVIDE(__stop_svc_data = .); 69 | } > RAM 70 | 71 | . = ALIGN(4); 72 | .dfu_trans : 73 | { 74 | PROVIDE(__start_dfu_trans = .); 75 | KEEP(*(.dfu_trans)) 76 | PROVIDE(__stop_dfu_trans = .); 77 | } > RAM 78 | 79 | } INSERT AFTER .data 80 | 81 | INCLUDE "nrf51_common.ld" 82 | -------------------------------------------------------------------------------- /nRF51822/flash_nrf.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/php 2 | . * 16 | */ 17 | 18 | // 19 | // first install php: 20 | // sudo apt-get install php 21 | // and use i.e. chmod 700 flash_nrf.php 22 | // 23 | 24 | function sendcmd($tfp,$cmd) { 25 | $pos=0; 26 | fputs($tfp,$cmd."\r"); 27 | do { 28 | $result=fread($tfp,4096); 29 | // echo "(".$pos.") [".$result,"]\n"; 30 | $pos++; 31 | } while (stripos($result,">")===false && $pos<20); 32 | usleep(500); // communication bonus 33 | return $result; 34 | } 35 | 36 | // main 37 | 38 | if ($argc!=2) { 39 | echo "Usage: ".$argv[0]." file.hex\n"; 40 | exit; 41 | } 42 | 43 | $ip = 'localhost'; 44 | $port = '4444'; 45 | $result = ''; 46 | $telnetfp = fsockopen($ip, $port); 47 | 48 | if ($telnetfp) { 49 | stream_set_timeout($telnetfp,20); // 20s should be enough 50 | //echo fgets($telnetfp); 51 | $result=fread($telnetfp,1024); 52 | if (stripos($result,"Open On-Chip Debugger")!==false) { 53 | echo "We are in!\n"; 54 | $result=sendcmd($telnetfp,"reset halt"); 55 | echo "reset halt ok!\n"; 56 | $result=sendcmd($telnetfp, "program ".$argv[1]," verify"); 57 | echo "program maybe ok!\n"; 58 | $result=sendcmd($telnetfp,"reset"); 59 | echo "reset ok!\n"; 60 | $result=sendcmd($telnetfp,"exit"); 61 | echo "exit ok!\n"; 62 | } else { 63 | echo "Sorry no openocd on Port 4444!\n"; 64 | } 65 | fclose($telnetfp); 66 | } else { 67 | echo "Sorry no openocd on Port 4444!\n"; 68 | } 69 | ?> 70 | -------------------------------------------------------------------------------- /nRF51822/gpiote/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | ASFLAGS += -g 8 | ASMFLAGS += -DBOARD_CUSTOM 9 | 10 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf51822_QFAA.ld 11 | 12 | # object files 13 | 14 | OBJS = system_nrf51.o 15 | OBJS += app_error.o app_util_platform.o nrf_assert.o nrf_drv_common.o nrf_delay.o 16 | OBJS += nrf_drv_gpiote.o 17 | OBJS += main.o 18 | 19 | # include common make file 20 | 21 | include $(TEMPLATEROOT)/Makefile.common 22 | -------------------------------------------------------------------------------- /nRF51822/gpiote/flash.txt: -------------------------------------------------------------------------------- 1 | openocd -d3 -f ../openocd.cfg 2 | telnet 127.0.0.1 4444 3 | reset halt 4 | nrf51 mass_erase 5 | ##flash banks 6 | reset halt 7 | program /home/pcbreflux/nordic/nordic.git/nRF51822/gpiote/_build/gpiote.hex verify 8 | reset 9 | 10 | -------------------------------------------------------------------------------- /nRF51822/gpiote/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * @defgroup pin_change_int_example_main main.c 15 | * @{ 16 | * @ingroup pin_change_int_example 17 | * @brief Pin Change Interrupt Example Application main file. 18 | * 19 | * This file contains the source code for a sample application using interrupts triggered by GPIO pins. 20 | * 21 | */ 22 | 23 | #include 24 | #include "nrf.h" 25 | #include "nrf_drv_gpiote.h" 26 | #include "app_error.h" 27 | #include "boards.h" 28 | 29 | #ifdef BSP_BUTTON_0 30 | #define PIN_IN BSP_BUTTON_0 31 | #endif 32 | #ifndef PIN_IN 33 | #error "Please indicate input pin" 34 | #endif 35 | 36 | #ifdef BSP_LED_0 37 | #define PIN_OUT BSP_LED_0 38 | #endif 39 | #ifndef PIN_OUT 40 | #error "Please indicate output pin" 41 | #endif 42 | 43 | void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) 44 | { 45 | nrf_drv_gpiote_out_toggle(PIN_OUT); 46 | } 47 | /** 48 | * @brief Function for configuring: PIN_IN pin for input, PIN_OUT pin for output, 49 | * and configures GPIOTE to give an interrupt on pin change. 50 | */ 51 | static void gpio_init(void) 52 | { 53 | ret_code_t err_code; 54 | 55 | err_code = nrf_drv_gpiote_init(); 56 | APP_ERROR_CHECK(err_code); 57 | 58 | nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false); 59 | 60 | err_code = nrf_drv_gpiote_out_init(PIN_OUT, &out_config); 61 | APP_ERROR_CHECK(err_code); 62 | 63 | nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true); 64 | in_config.pull = NRF_GPIO_PIN_PULLUP; 65 | 66 | err_code = nrf_drv_gpiote_in_init(PIN_IN, &in_config, in_pin_handler); 67 | APP_ERROR_CHECK(err_code); 68 | 69 | nrf_drv_gpiote_in_event_enable(PIN_IN, true); 70 | } 71 | 72 | /** 73 | * @brief Function for application main entry. 74 | */ 75 | int main(void) 76 | { 77 | gpio_init(); 78 | 79 | while (true) 80 | { 81 | // Do nothing. 82 | } 83 | } 84 | 85 | 86 | /** @} */ 87 | -------------------------------------------------------------------------------- /nRF51822/openocd.cfg: -------------------------------------------------------------------------------- 1 | #nRF51822 Target 2 | source [find interface/stlink-v2.cfg] 3 | 4 | transport select hla_swd 5 | 6 | set WORKAREASIZE 0x4000 7 | source [find target/nrf51.cfg] 8 | 9 | -------------------------------------------------------------------------------- /nRF51822/qdec_rotary_encoder/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | ASFLAGS += -g 8 | ASMFLAGS += -DBOARD_CUSTOM 9 | 10 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf51822_QFAA.ld 11 | 12 | # object files 13 | 14 | OBJS = system_nrf51.o 15 | OBJS += app_error.o app_fifo.o app_util_platform.o nrf_assert.o app_uart_fifo.o nrf_drv_common.o nrf_delay.o nrf_drv_uart.o 16 | OBJS += nrf_drv_qdec.o 17 | OBJS += uart.o main.o 18 | 19 | # include common make file 20 | 21 | include $(TEMPLATEROOT)/Makefile.common 22 | -------------------------------------------------------------------------------- /nRF51822/qdec_rotary_encoder/flash.txt: -------------------------------------------------------------------------------- 1 | openocd -d3 -f ../openocd.cfg 2 | ./flash_nrf.php /home/pcbreflux/nordic/nordic.git/nRF51822/qdec_rotary_encoder/_build/qdec_rotary_encoder.hex 3 | -------------------------------------------------------------------------------- /nRF51822/qdec_rotary_encoder/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | /** @file main.c (changed by pcbreflux) 17 | * @brief QDEC and Rotary Encoder Example Application main file. 18 | * 19 | */ 20 | #include 21 | #include "app_uart.h" 22 | #include "app_error.h" 23 | #include "nrf_delay.h" 24 | #include "nrf_gpio.h" 25 | #include "boards.h" 26 | #include "nrf_drv_qdec.h" 27 | #include "uart.h" 28 | 29 | static volatile uint32_t m_accdblread; 30 | static volatile int32_t m_accread; 31 | static volatile int32_t m_value=0; 32 | static volatile int32_t m_last_value=0; 33 | 34 | 35 | /** @brief Function initialization and configuration GPIO pins. 36 | */ 37 | static void gpio_config(void) { 38 | // Configure Pins as inputs with pull-up. 39 | nrf_gpio_cfg_input(QDEC_CONFIG_PIO_A,NRF_GPIO_PIN_PULLUP); 40 | nrf_gpio_cfg_input(QDEC_CONFIG_PIO_B,NRF_GPIO_PIN_PULLUP); 41 | } 42 | 43 | /** @brief Function handle qdec events. 44 | */ 45 | static void qdec_event_handler(nrf_drv_qdec_event_t event) { 46 | if (event.type == NRF_QDEC_EVENT_REPORTRDY) { 47 | m_accdblread = event.data.report.accdbl; 48 | m_accread = event.data.report.acc; 49 | if (m_accdblread==0) { 50 | m_value += m_accread; 51 | } 52 | if (m_value<0) { 53 | m_value = 0; 54 | } else if (m_value>100) { 55 | m_value=100; 56 | } 57 | if (m_value != m_last_value) { 58 | uart_printf("report dbl=%u acc=%d",m_accdblread,m_accread); 59 | if (m_accread>0) { 60 | uart_printf("\x1B[1;32m"); // GREEN 61 | } else { 62 | uart_printf("\x1B[1;31m"); // RED 63 | } 64 | uart_printf(" val=%d\n\r",m_value); 65 | m_last_value = m_value; 66 | uart_printf("\x1B[0m"); // DEFAULT color 67 | } 68 | } 69 | } 70 | 71 | /** @brief Function initialization and configuration of QDEC driver instance. 72 | */ 73 | static void qdec_config(void) { 74 | uint32_t err_code; 75 | 76 | nrf_drv_qdec_config_t qdec_config = NRF_DRV_QDEC_DEFAULT_CONFIG; 77 | // Initialize hardware 78 | err_code = nrf_drv_qdec_init(&qdec_config, qdec_event_handler); 79 | APP_ERROR_CHECK(err_code); 80 | 81 | printf("QDEC testing started\n"); 82 | uart_printf("nrf_drv_qdec_init\n\r"); 83 | 84 | nrf_drv_qdec_enable(); // Event and corresponding interrupt are enabled. 85 | uart_printf("nrf_drv_qdec_enable \n\r"); 86 | } 87 | 88 | /** 89 | * @brief Function for application main entry. 90 | */ 91 | int main(void) { 92 | uart_init(); 93 | uart_printf("\n\rstart qdec\n\r"); 94 | 95 | // setup 96 | gpio_config(); // Configure GPIO pins. 97 | qdec_config(); // Configure QDEC 98 | 99 | // loop 100 | while (true) { 101 | // Enter System ON sleep mode 102 | __WFE(); 103 | // Make sure any pending events are cleared 104 | __SEV(); 105 | __WFE(); 106 | } 107 | } 108 | 109 | 110 | /** @} */ 111 | -------------------------------------------------------------------------------- /nRF51822/qdec_rotary_encoder/uart.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | 17 | /** 18 | * @brief UART header file. 19 | * 20 | * This file contains the source code for a application using UART. 21 | * 22 | */ 23 | #include 24 | #include "app_uart.h" 25 | #include "app_error.h" 26 | #include "nrf.h" 27 | //#include "nrf_drv_config.h" 28 | #include "bsp.h" 29 | #include "uart.h" 30 | 31 | #define MAX_TEST_DATA_BYTES (15U) /**< max number of test bytes to be used for tx and rx. */ 32 | #define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */ 33 | #define UART_RX_BUF_SIZE 1 /**< UART RX buffer size. */ 34 | 35 | /** 36 | * @brief Function for uart_error_handle uart error handling. 37 | */ 38 | void uart_error_handle(app_uart_evt_t * p_event) { 39 | if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR) { 40 | APP_ERROR_HANDLER(p_event->data.error_communication); 41 | } else if (p_event->evt_type == APP_UART_FIFO_ERROR) { 42 | APP_ERROR_HANDLER(p_event->data.error_code); 43 | } 44 | } 45 | 46 | 47 | /** 48 | * @brief Function for uart_write write string to uart function. 49 | * @param out output string 50 | */ 51 | void uart_write(const char* out) { 52 | while(*out) { 53 | while(app_uart_put(*out++) != NRF_SUCCESS); 54 | } 55 | } 56 | 57 | /** 58 | * @brief Function for uart_printf print formated to uart function. 59 | * @param format_out output format 60 | * @param ... output variables 61 | */ 62 | void uart_printf(const char * format_out, ...) { 63 | static char outbuffer[256]; 64 | 65 | va_list p_args; 66 | va_start(p_args, format_out); 67 | vsprintf(outbuffer, format_out, p_args); 68 | va_end(p_args); 69 | uart_write(outbuffer); 70 | } 71 | 72 | /** 73 | * @brief Function for uart_init initialise my uart function. 74 | */ 75 | void uart_init(void) { 76 | uint32_t err_code; 77 | 78 | const app_uart_comm_params_t comm_params = { 79 | RX_PIN_NUMBER, 80 | TX_PIN_NUMBER, 81 | RTS_PIN_NUMBER, 82 | CTS_PIN_NUMBER, 83 | HWFC?APP_UART_FLOW_CONTROL_ENABLED:APP_UART_FLOW_CONTROL_DISABLED, 84 | false, // use_parity 85 | UART0_CONFIG_BAUDRATE 86 | }; 87 | 88 | APP_UART_FIFO_INIT(&comm_params, 89 | UART_RX_BUF_SIZE, 90 | UART_TX_BUF_SIZE, 91 | uart_error_handle, 92 | APP_IRQ_PRIORITY_LOW, 93 | err_code); 94 | 95 | APP_ERROR_CHECK(err_code); 96 | } 97 | 98 | -------------------------------------------------------------------------------- /nRF51822/qdec_rotary_encoder/uart.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | 17 | #ifndef UART_H 18 | #define UART_H 19 | /** 20 | * @brief UART header file. 21 | * 22 | * This file contains the defining code for a application using UART. 23 | * 24 | */ 25 | 26 | /** 27 | * @brief Function for uart_error_handle uart error handling. 28 | */ 29 | void uart_error_handle(app_uart_evt_t * p_event); 30 | 31 | /** 32 | * @brief Function for uart_write write string to uart function. 33 | * @param out output string 34 | */ 35 | void uart_write(const char* out); 36 | 37 | /** 38 | * @brief Function for uart_printf print formated to uart function. 39 | * @param format_out output format 40 | * @param ... output variables 41 | */ 42 | void uart_printf(const char * format_out, ...); 43 | 44 | /** 45 | * @brief Function for uart_init initialise my uart function. 46 | */ 47 | void uart_init(void); 48 | 49 | #endif // UART_H 50 | -------------------------------------------------------------------------------- /nRF51822/rtc_blinky/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | ASFLAGS += -g 7 | 8 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf51822_QFAA.ld 9 | 10 | # object files 11 | 12 | OBJS = system_nrf51.o app_error.o app_util_platform.o nrf_drv_clock.o nrf_drv_common.o nrf_drv_rtc.o 13 | OBJS += rtc_blinky.o 14 | 15 | # include common make file 16 | 17 | include $(TEMPLATEROOT)/Makefile.common 18 | -------------------------------------------------------------------------------- /nRF51822/rtc_blinky/flash.txt: -------------------------------------------------------------------------------- 1 | openocd -d3 -f ../openocd.cfg 2 | telnet 127.0.0.1 4444 3 | reset halt 4 | nrf51 mass_erase 5 | ##flash banks 6 | halt 7 | program /home/pcbreflux/nordic/nordic.git/nRF51822/rtc_blinky/_build/rtc_blinky.hex verify 8 | reset 9 | 10 | -------------------------------------------------------------------------------- /nRF51822/rtc_blinky/nrf_drv_config.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef NRF_DRV_CONFIG_H 14 | #define NRF_DRV_CONFIG_H 15 | 16 | /** 17 | * Provide a non-zero value here in applications that need to use several 18 | * peripherals with the same ID that are sharing certain resources 19 | * (for example, SPI0 and TWI0). Obviously, such peripherals cannot be used 20 | * simultaneously. Therefore, this definition allows to initialize the driver 21 | * for another peripheral from a given group only after the previously used one 22 | * is uninitialized. Normally, this is not possible, because interrupt handlers 23 | * are implemented in individual drivers. 24 | * This functionality requires a more complicated interrupt handling and driver 25 | * initialization, hence it is not always desirable to use it. 26 | */ 27 | #define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 28 | 29 | /* CLOCK */ 30 | #define CLOCK_ENABLED 1 31 | #define CLOCK_CONFIG_XTAL_FREQ NRF_CLOCK_XTALFREQ_Default 32 | #define CLOCK_CONFIG_LF_SRC NRF_CLOCK_LFCLK_Xtal 33 | #define CLOCK_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 34 | 35 | /* RTC */ 36 | #define RTC0_ENABLED 0 37 | 38 | #if (RTC0_ENABLED == 1) 39 | #define RTC0_CONFIG_FREQUENCY 8 40 | #define RTC0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 41 | #define RTC0_CONFIG_RELIABLE false 42 | 43 | #define RTC0_INSTANCE_INDEX 0 44 | #endif 45 | 46 | #define RTC1_ENABLED 1 47 | 48 | #if (RTC1_ENABLED == 1) 49 | #define RTC1_CONFIG_FREQUENCY 8 50 | #define RTC1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 51 | #define RTC1_CONFIG_RELIABLE false 52 | 53 | #define RTC1_INSTANCE_INDEX (RTC0_ENABLED) 54 | #endif 55 | 56 | #define RTC2_ENABLED 0 57 | 58 | #if (RTC2_ENABLED == 1) 59 | #define RTC2_CONFIG_FREQUENCY 32768 60 | #define RTC2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 61 | #define RTC2_CONFIG_RELIABLE false 62 | 63 | #define RTC2_INSTANCE_INDEX (RTC0_ENABLED+RTC1_ENABLED) 64 | #endif 65 | 66 | 67 | #define RTC_COUNT (RTC0_ENABLED+RTC1_ENABLED+RTC2_ENABLED) 68 | 69 | #define NRF_MAXIMUM_LATENCY_US 2000 70 | 71 | #include "nrf_drv_config_validation.h" 72 | 73 | #endif // NRF_DRV_CONFIG_H 74 | -------------------------------------------------------------------------------- /nRF51822/rtc_blinky/rtc_blinky.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file rtc_blinky.c (changed by pcbreflux) 14 | * @brief Blinky Example Application main file. 15 | * 16 | */ 17 | #include 18 | #include "nrf_delay.h" 19 | #include "nrf_gpio.h" 20 | #include "nrf_drv_clock.h" 21 | #include "nrf_drv_rtc.h" 22 | #include "app_error.h" 23 | 24 | // see nrf_drv_config.h for defining RTC1 25 | #define RTC1_CC_VALUE 8 // 125ms*8*1=1s 26 | // Softdevice S110, S120, S130 blocks RTC0 27 | const nrf_drv_rtc_t rtc1 = NRF_DRV_RTC_INSTANCE(1); /**< Declaring an instance of nrf_drv_rtc for RTC1. */ 28 | 29 | const uint32_t led_pin1 = 19; 30 | 31 | /** @brief Function initialization and configuration of RTC driver instance. 32 | */ 33 | static void gpio_config(void) { 34 | // Configure LED-pin as outputs and clear. 35 | nrf_gpio_cfg_output(led_pin1); 36 | nrf_gpio_pin_clear(led_pin1); 37 | } 38 | 39 | static void rtc1_handler(nrf_drv_rtc_int_type_t int_type) { 40 | // uint32_t err_code; 41 | 42 | if (int_type == NRF_DRV_RTC_INT_COMPARE0) { // Interrupt from COMPARE0 event. 43 | nrf_gpio_pin_set(led_pin1); 44 | nrf_drv_rtc_int_enable(&rtc1, RTC_CHANNEL_INT_MASK(0)); 45 | } else if (int_type == NRF_DRV_RTC_INT_COMPARE1) { // Interrupt from COMPARE1 event. 46 | nrf_gpio_pin_clear(led_pin1); 47 | nrf_drv_rtc_int_enable(&rtc1, RTC_CHANNEL_INT_MASK(1)); 48 | } else if (int_type == NRF_DRV_RTC_INT_COMPARE2) { // Interrupt from COMPARE2 event. 49 | nrf_drv_rtc_counter_clear(&rtc1); 50 | nrf_drv_rtc_int_enable(&rtc1, RTC_CHANNEL_INT_MASK(2)); 51 | } else if (int_type == NRF_DRV_RTC_INT_TICK) { // Tick off 52 | nrf_gpio_pin_toggle(led_pin1); 53 | } 54 | } 55 | 56 | /** @brief Function starting the internal LFCLK XTAL oscillator. 57 | */ 58 | static void lfclk_config(void) { 59 | ret_code_t err_code = nrf_drv_clock_init(); 60 | APP_ERROR_CHECK(err_code); 61 | 62 | nrf_drv_clock_lfclk_request(NULL); 63 | } 64 | 65 | /** @brief Function initialization and configuration of RTC driver instance. 66 | */ 67 | static void rtc_config(void) { 68 | uint32_t err_code; 69 | 70 | //Initialize RTC instance 71 | err_code = nrf_drv_rtc_init(&rtc1, NULL, rtc1_handler); 72 | APP_ERROR_CHECK(err_code); 73 | 74 | //Disable tick event & interrupt 75 | nrf_drv_rtc_tick_enable(&rtc1,false); 76 | 77 | /* 78 | |----| |----| 79 | | | | | 80 | ____| |______________________..._____| |____... 81 | 1s 1s 8s 1s 1s 82 | */ 83 | 84 | //Set compare channel 0 to trigger interrupt after RTC1_CC_VALUE*125ms 85 | err_code = nrf_drv_rtc_cc_set(&rtc1,0,RTC1_CC_VALUE,true); 86 | APP_ERROR_CHECK(err_code); 87 | 88 | //Set compare channel 1 to trigger interrupt after RTC1_CC_VALUE*125ms*2 89 | err_code = nrf_drv_rtc_cc_set(&rtc1,1,RTC1_CC_VALUE*2,true); 90 | APP_ERROR_CHECK(err_code); 91 | 92 | //Set compare channel 2 to trigger interrupt after RTC1_CC_VALUE*125ms*9 93 | err_code = nrf_drv_rtc_cc_set(&rtc1,2,RTC1_CC_VALUE*10,true); 94 | APP_ERROR_CHECK(err_code); 95 | 96 | //Power on RTC instance 97 | nrf_drv_rtc_enable(&rtc1); 98 | } 99 | 100 | /** 101 | * @brief Function for application main entry. 102 | */ 103 | int main(void) { 104 | 105 | // setup 106 | gpio_config(); 107 | lfclk_config(); 108 | rtc_config(); 109 | 110 | // loop 111 | while (true) { 112 | // Enter System ON sleep mode 113 | __WFE(); 114 | // Make sure any pending events are cleared 115 | __SEV(); 116 | __WFE(); 117 | } 118 | } 119 | 120 | 121 | /** @} */ 122 | -------------------------------------------------------------------------------- /nRF51822/s110_nrf51822_QFAA.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x18000, LENGTH = 0x28000 9 | RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data_out ALIGN(4): 15 | { 16 | PROVIDE( __start_fs_data = .); 17 | KEEP(*(fs_data)) 18 | PROVIDE( __stop_fs_data = .); 19 | } = 0 20 | } 21 | 22 | INCLUDE "nrf5x_common.ld" -------------------------------------------------------------------------------- /nRF51822/s110_nrf51822_QFAC.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x18000, LENGTH = 0x28000 9 | RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x6000 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data_out ALIGN(4): 15 | { 16 | PROVIDE( __start_fs_data = .); 17 | KEEP(*(fs_data)) 18 | PROVIDE( __stop_fs_data = .); 19 | } = 0 20 | } 21 | 22 | INCLUDE "nrf5x_common.ld" -------------------------------------------------------------------------------- /nRF51822/s130_nrf51822_QFAA.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x1c000, LENGTH = 0x24000 9 | RAM (rwx) : ORIGIN = 0x20002800, LENGTH = 0x1800 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data_out ALIGN(4): 15 | { 16 | PROVIDE( __start_fs_data = .); 17 | KEEP(*(fs_data)) 18 | PROVIDE( __stop_fs_data = .); 19 | } = 0 20 | } 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /nRF51822/s130_nrf51822_QFAC.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x1c000, LENGTH = 0x24000 9 | RAM (rwx) : ORIGIN = 0x20002800, LENGTH = 0x5800 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data_out ALIGN(4): 15 | { 16 | PROVIDE( __start_fs_data = .); 17 | KEEP(*(fs_data)) 18 | PROVIDE( __stop_fs_data = .); 19 | } = 0 20 | } 21 | 22 | INCLUDE "nrf5x_common.ld" -------------------------------------------------------------------------------- /nRF51822/s130_v2_nrf51822_QFAA.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x25000 9 | RAM (rwx) : ORIGIN = 0x20001870, LENGTH = 0x2790 10 | } 11 | 12 | SECTIONS 13 | { 14 | .fs_data_out ALIGN(4): 15 | { 16 | PROVIDE( __start_fs_data = .); 17 | KEEP(*(fs_data)) 18 | PROVIDE( __stop_fs_data = .); 19 | } = 0 20 | } 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /nRF51822/s130_v2_nrf51822_QFAC.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x25000 9 | RAM (rwx) : ORIGIN = 0x20001870, LENGTH = 0x6790 10 | } 11 | 12 | SECTIONS 13 | { 14 | . = ALIGN(4); 15 | .fs_data : 16 | { 17 | PROVIDE(__start_fs_data = .); 18 | KEEP(*(.fs_data)) 19 | PROVIDE(__stop_fs_data = .); 20 | } > RAM 21 | } INSERT AFTER .data; 22 | 23 | INCLUDE "nrf5x_common.ld" 24 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF51822 8 | CFLAGS += -DNRF_LOG_USES_UART=1 9 | ASFLAGS += -g 10 | ASMFLAGS += -DBOARD_CUSTOM 11 | ASMFLAGS += -DNRF51822 12 | ASMFLAGS += -DNRF_LOG_USES_UART=1 13 | 14 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf51822_QFAA.ld 15 | 16 | # object files 17 | 18 | OBJS = system_nrf51.o nrf_log_backend_serial.o nrf_log_frontend.o 19 | OBJS += app_error_weak.o app_error.o app_fifo.o app_util_platform.o nrf_assert.o app_uart_fifo.o nrf_drv_common.o nrf_drv_uart.o 20 | OBJS += nrf_drv_spi.o 21 | OBJS += xprintf.o tm_stm32f4_fonts.o ili9341.o main.o 22 | 23 | # include common make file 24 | 25 | include $(TEMPLATEROOT)/Makefile.common 26 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341/flash.txt: -------------------------------------------------------------------------------- 1 | make flash 2 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341/ili9341.h: -------------------------------------------------------------------------------- 1 | #ifndef ILI9341_H 2 | #define ILI9341_H 3 | 4 | #define ILI9341_DEFAULT_CONFIG { \ 5 | .mosi_pin = SPIM0_MOSI_PIN, \ 6 | .sck_pin = SPIM0_SCK_PIN, \ 7 | .cs_pin = SPIM0_SS_PIN, \ 8 | .dc_pin = 0xFF, \ 9 | .rst_pin = 0xFF, \ 10 | .bkl_pin = 0xFF \ 11 | } 12 | 13 | /**@brief ILI9341 configuration structure.*/ 14 | typedef struct { 15 | uint32_t mosi_pin; /**< Pin number for MOSI output. */ 16 | uint32_t sck_pin; /**< Pin number for CLK output. */ 17 | uint32_t cs_pin; /**< Pin number for client select/Load output. */ 18 | uint32_t dc_pin; /**< Pin number for 1 = data, 0 = control output. */ 19 | uint32_t rst_pin; /**< Pin number for client select/Load output. */ 20 | uint32_t bkl_pin; /**< Pin number for led backlight output. */ 21 | } ili9341_config_t; 22 | 23 | /* Colors are 565 RGB (5 bits Red, 6 bits green, 5 bits blue) */ 24 | 25 | #define BLACK 0x0000 26 | #define BLUE 0x001F 27 | #define GREEN 0x07E0 28 | #define CYAN 0x07FF 29 | #define RED 0xF800 30 | #define MAGENTA 0xF81F 31 | #define YELLOW 0xFFE0 32 | #define WHITE 0xFFFF 33 | 34 | #define SPILCD SPI2 35 | 36 | /* MADCTL [MY MX MV] 37 | * MY row address order 1 (bottom to top), 0 (top to bottom) 38 | * MX col address order 1 (right to left), 0 (left to right) 39 | * MV col/row exchange 1 (exchange), 0 normal 40 | */ 41 | 42 | /* Transparent background, only for strings and chars */ 43 | #define ILI9341_TRANSPARENT 0x80000000 44 | 45 | #define MADCTLGRAPHICS 0x6 46 | #define MADCTLBMP 0x2 47 | 48 | #define ILI9341_width 320 49 | #define ILI9341_height 240 50 | 51 | void ILI9341_setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); 52 | void ILI9341_init(); 53 | void ILI9341_backLight(uint8_t on); 54 | void ILI9341_Putc(uint16_t x, uint16_t y, char c, TM_FontDef_t *font, uint32_t foreground, uint32_t background); 55 | void ILI9341_Puts(uint16_t x, uint16_t y, char *str, TM_FontDef_t *font, uint32_t foreground, uint32_t background); 56 | void ILI9341_fillscreen(uint16_t color); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | /** @file main.c (changed by pcbreflux) 17 | * @brief SPI Example Application main file. 18 | * 19 | */ 20 | #include 21 | #include "nrf_delay.h" 22 | #include "nrf_gpio.h" 23 | #include "boards.h" 24 | #include "sdk_config.h" 25 | #define NRF_LOG_MODULE_NAME "PCBREFLUX SPI" 26 | #include "nrf_log.h" 27 | #include "nrf_log_ctrl.h" 28 | #include "nrf_drv_spi.h" 29 | #include "app_uart.h" 30 | #include "app_error.h" 31 | #include "tm_stm32f4_fonts.h" 32 | #include "ili9341.h" 33 | #include "xprintf.h" 34 | 35 | #define MAX7221_DEVCNT 5 36 | 37 | // see nrf_drv_config.h for defining TIMER1 38 | // Softdevice S110, S120, S130 blocks TIMER0 39 | const nrf_drv_spi_t my_spi_0 = NRF_DRV_SPI_INSTANCE(0); /**< Declaring an instance of nrf_drv_spi for SPI0. */ 40 | 41 | /** @brief Function initialization and configuration of RTC driver instance. 42 | */ 43 | static void gpio_config(ili9341_config_t const * const ili9341_config) { 44 | // Configure ILI9341-pin as outputs and clear. 45 | nrf_gpio_cfg_output(ili9341_config->cs_pin); 46 | nrf_gpio_pin_set(ili9341_config->cs_pin); 47 | nrf_gpio_cfg_output(ili9341_config->dc_pin); 48 | nrf_gpio_pin_clear(ili9341_config->dc_pin); 49 | nrf_gpio_cfg_output(ili9341_config->rst_pin); 50 | nrf_gpio_pin_clear(ili9341_config->rst_pin); 51 | nrf_gpio_cfg_output(ili9341_config->bkl_pin); 52 | nrf_gpio_pin_set(ili9341_config->bkl_pin); 53 | 54 | 55 | } 56 | 57 | /** @brief Function initialization and configuration of RTC driver instance. 58 | */ 59 | static void spi_config(ili9341_config_t const * const ili9341_config) { 60 | ret_code_t err_code; 61 | 62 | nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG; 63 | 64 | NRF_LOG_INFO("spi config %d %d %d\n\r",ili9341_config->mosi_pin,ili9341_config->sck_pin,ili9341_config->cs_pin); 65 | spi_config.sck_pin = ili9341_config->sck_pin; 66 | spi_config.mosi_pin = ili9341_config->mosi_pin; 67 | spi_config.ss_pin = 0xFF; // external usage 68 | //spi_config.frequency = NRF_DRV_SPI_FREQ_125K; // tCP = 100ns see MAX7219/MAX7221 Datasheet TIMING CHARACTERISTICS 69 | spi_config.frequency = NRF_DRV_SPI_FREQ_8M; // tCP = 100ns see MAX7219/MAX7221 Datasheet TIMING CHARACTERISTICS 70 | spi_config.mode = NRF_DRV_SPI_MODE_0; // SCK active high, sample on leading edge of clock. 71 | spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST; 72 | 73 | err_code = nrf_drv_spi_init(&my_spi_0,&spi_config,NULL); 74 | APP_ERROR_CHECK(err_code); 75 | 76 | } 77 | 78 | 79 | uint8_t TxBuffer[513]; 80 | 81 | /** 82 | * @brief Function for application main entry. 83 | */ 84 | int main(void) { 85 | // uint32_t retVal; 86 | uint32_t pos=0; 87 | int i,iLine; 88 | 89 | APP_ERROR_CHECK(NRF_LOG_INIT(NULL)); 90 | 91 | NRF_LOG_INFO("main spi_config\n\r"); 92 | ili9341_config_t ili9341_config = ILI9341_DEFAULT_CONFIG; 93 | ili9341_config.dc_pin = 19; 94 | ili9341_config.rst_pin = 20; 95 | ili9341_config.bkl_pin = 21; 96 | 97 | // setup 98 | gpio_config(&ili9341_config); // Configure GPIO pins. 99 | spi_config(&ili9341_config); 100 | 101 | NRF_LOG_INFO("main ILI9341_init\n\r"); 102 | NRF_LOG_FLUSH(); 103 | ILI9341_init(&my_spi_0,&ili9341_config); 104 | ILI9341_backLight(1); 105 | 106 | // ILI9341_fillscreen(0); // yes this sucks 107 | 108 | NRF_LOG_INFO("main loop\n\r"); 109 | // loop 110 | while (true) { 111 | for (i=0;i<3;i++) { 112 | for (iLine=0;iLine<3;iLine++) { 113 | pos++; 114 | xsprintf((char *)TxBuffer,"nRF51822 (16MHz) + ILI9341 via SPI 8MHz %d ",pos); 115 | ILI9341_Puts(0, iLine*10, (char *)TxBuffer, &TM_Font_7x10, 0xFFFF, pos); 116 | } 117 | for (iLine=4;iLine<8;iLine++) { 118 | pos++; 119 | xsprintf((char *)TxBuffer,"nRF51822 + ILI9341 %d ",pos); 120 | ILI9341_Puts(0, iLine*18-40, (char *)TxBuffer, &TM_Font_11x18, 0xFFFF, pos); 121 | } 122 | for (iLine=8;iLine<13;iLine++) { 123 | pos++; 124 | xsprintf((char *)TxBuffer,"nRF51822+TTF %d ",pos); 125 | ILI9341_Puts(0, iLine*26-100, (char *)TxBuffer, &TM_Font_16x26, 0xFFFF, pos); 126 | } 127 | } 128 | NRF_LOG_INFO("tick (%u)\n\r",pos); 129 | 130 | } 131 | } 132 | 133 | 134 | /** @} */ 135 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341/stm32_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "uartdma.h" 8 | #include "spidma.h" 9 | #include "xprintf.h" 10 | #include "tm_stm32f4_fonts.h" 11 | #include "ili9341.h" 12 | 13 | #define TEST_BUFFER_SIZE 20 14 | 15 | static __IO uint32_t TimingDelay; 16 | 17 | void Delay(uint32_t nTime); 18 | 19 | uint8_t TxBuffer[513]; 20 | uint8_t TxOutBuffer[513]; 21 | uint8_t wbuf[TEST_BUFFER_SIZE], rbuf[TEST_BUFFER_SIZE]; 22 | uint16_t wbuf16[TEST_BUFFER_SIZE], rbuf16[TEST_BUFFER_SIZE]; 23 | #define countof(a) (sizeof(a) / sizeof(*(a))) 24 | 25 | 26 | int main(void) { 27 | 28 | if (SysTick_Config(SystemCoreClock/1000)) 29 | while(1); 30 | 31 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); 32 | 33 | GPIO_InitTypeDef GPIO_InitStructure; 34 | 35 | GPIO_StructInit(&GPIO_InitStructure); 36 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; 37 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 38 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 39 | GPIO_Init(GPIOC, &GPIO_InitStructure); 40 | 41 | uart_init(USART1, 57600, USART_Mode_Rx | USART_Mode_Tx); 42 | // spi_init(SPI2); 43 | 44 | uint16_t iCount1 = 0; 45 | uint16_t iCount2 = 0; 46 | uint16_t iCount3 = 0; 47 | int i,j, iLine; 48 | static int ledval = 1; 49 | 50 | ILI9341_backLight(1); 51 | xsprintf((char *)TxBuffer,"STM32F103xx pre ILI9341_init [%d] \n",iCount1); 52 | uart_write(USART1,TxBuffer,countof(TxBuffer)-1); 53 | ILI9341_init(); 54 | xsprintf((char *)TxBuffer,"STM32F103xx post ILI9341_init [%d] \n",iCount1); 55 | uart_write(USART1,TxBuffer,countof(TxBuffer)-1); 56 | 57 | ILI9341_fillscreen(0); // yes this sucks 58 | //xsprintf((char *)TxOutBuffer,"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS"); 59 | //iCount3 = countof(TxOutBuffer)-1; 60 | while (1) { 61 | 62 | if (iCount1%10==0) { 63 | xsprintf((char *)TxBuffer,"STM32F103xx [%d] \n ",iCount1); 64 | uart_write(USART1,TxBuffer,countof(TxBuffer)-1); 65 | } 66 | 67 | xsprintf((char *)TxBuffer," "); 68 | for (iLine=0;iLine<9;iLine++) { // lazy clear screen - yes it's lame 69 | ILI9341_Puts(0, iLine*26,(char *)TxBuffer, &TM_Font_16x26, 0x0000, 0x0000); 70 | } 71 | 72 | for (i=0;i<3;i++) { 73 | for (iLine=0;iLine<23;iLine++) { 74 | xsprintf((char *)TxBuffer,"STM32F103xx + ILI9341 Line %d",iLine); 75 | ILI9341_Puts(0, iLine*10,(char *)TxBuffer, &TM_Font_7x10, iCount1+iLine, 0xFFFF); 76 | } 77 | 78 | for (iLine=0;iLine<23;iLine++) { 79 | xsprintf((char *)TxBuffer,"STM32F103xx + ILI9341 Line %d",iLine); 80 | ILI9341_Puts(0, iLine*10, (char *)TxBuffer, &TM_Font_7x10, 0xFFFF, iCount1+iLine); 81 | } 82 | } 83 | xsprintf((char *)TxBuffer," "); 84 | for (iLine=0;iLine<9;iLine++) { 85 | ILI9341_Puts(0, iLine*26,(char *)TxBuffer, &TM_Font_16x26, 0x0000, 0x0000); 86 | } 87 | for (i=0;i<3;i++) { 88 | for (iLine=0;iLine<13;iLine++) { 89 | xsprintf((char *)TxBuffer,"STM32F103xx + ILI9341 Line %d",iLine); 90 | ILI9341_Puts(0, iLine*18,(char *)TxBuffer, &TM_Font_11x18, iCount1+iLine, 0xFFFF); 91 | } 92 | 93 | for (iLine=0;iLine<13;iLine++) { 94 | xsprintf((char *)TxBuffer,"STM32F103xx + ILI9341 Line %d",iLine); 95 | ILI9341_Puts(0, iLine*18, (char *)TxBuffer, &TM_Font_11x18, 0xFFFF, iCount1+iLine); 96 | } 97 | } 98 | for (iLine=0;iLine<9;iLine++) { 99 | ILI9341_Puts(0, iLine*26,(char *)TxBuffer, &TM_Font_16x26, 0x0000, 0x0000); 100 | } 101 | for (i=0;i<3;i++) { 102 | for (iLine=0;iLine<9;iLine++) { 103 | xsprintf((char *)TxBuffer,"STM32F103xx Line %d",iLine); 104 | ILI9341_Puts(0, iLine*26,(char *)TxBuffer, &TM_Font_16x26, iCount1+iLine, 0xFFFF); 105 | } 106 | 107 | for (iLine=0;iLine<9;iLine++) { 108 | xsprintf((char *)TxBuffer,"STM32F103xx Line %d",iLine); 109 | ILI9341_Puts(0, iLine*26, (char *)TxBuffer, &TM_Font_16x26, 0xFFFF, iCount1+iLine); 110 | } 111 | } 112 | /* 113 | 114 | ILI9341_dup_print("H E L L O m y S T M 3 2 !", 1,0, iCount1, 0x0000); 115 | // ILI9341_dup_print(TxOutBuffer+iCount2, 14,0, iCount1, 0x0000); 116 | 117 | Delay(5000); 118 | */ 119 | iCount1++; 120 | /* 121 | iCount2++; 122 | if (iCount1==0xFFFF) { 123 | iCount1=0; 124 | } 125 | Delay(10); 126 | if (iCount2==iCount3) { 127 | iCount2=0; 128 | } 129 | */ 130 | 131 | } 132 | } 133 | 134 | 135 | 136 | void Delay(uint32_t nTime) { 137 | TimingDelay = nTime; 138 | while (TimingDelay != 0); 139 | } 140 | 141 | void SysTick_Handler(void) { 142 | if (TimingDelay != 0x00) { 143 | TimingDelay--; 144 | } 145 | } 146 | 147 | #ifdef USE_FULL_ASSERT 148 | void assert_failed(uint8_t* file, uint32_t line) { 149 | while (1); 150 | } 151 | #endif 152 | 153 | 154 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341/tm_stm32f4_fonts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Tilen Majerle 3 | * @email tilen@majerle.eu 4 | * @website http://stm32f4-discovery.com 5 | * @link 6 | * @version v1.0 7 | * @ide Keil uVision 8 | * @license GNU GPL v3 9 | * @brief Fonts library for LCD libraries 10 | * 11 | @verbatim 12 | ---------------------------------------------------------------------- 13 | Copyright (C) Tilen Majerle, 2015 14 | 15 | This program is free software: you can redistribute it and/or modify 16 | it under the terms of the GNU General Public License as published by 17 | the Free Software Foundation, either version 3 of the License, or 18 | any later version. 19 | 20 | This program is distributed in the hope that it will be useful, 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | GNU General Public License for more details. 24 | 25 | You should have received a copy of the GNU General Public License 26 | along with this program. If not, see . 27 | ---------------------------------------------------------------------- 28 | @endverbatim 29 | */ 30 | #ifndef TM_FONTS_H 31 | #define TM_FONTS_H 110 32 | 33 | /* C++ detection */ 34 | #ifdef __cplusplus 35 | extern C { 36 | #endif 37 | 38 | /** 39 | * @addtogroup TM_STM32F4xx_Libraries 40 | * @{ 41 | */ 42 | 43 | /** 44 | * @defgroup TM_FONTS 45 | * @brief Fonts library for all my LCD libraries 46 | * @{ 47 | * 48 | * Default fonts library. It is used in all LCD based libraries. 49 | * 50 | * \par Supported fonts 51 | * 52 | * Currently, these fonts are supported: 53 | * - 7 x 10 pixels 54 | * - 11 x 18 pixels 55 | * - 16 x 26 pixels 56 | * 57 | * \par Changelog 58 | * 59 | @verbatim 60 | Version 1.0 61 | - First release 62 | @endverbatim 63 | * 64 | * \par Dependencies 65 | * 66 | @verbatim 67 | - STM32F4xx 68 | - STM32F4xx RCC 69 | - defines.h 70 | @endverbatim 71 | */ 72 | 73 | /** 74 | * @defgroup TM_LIB_Typedefs 75 | * @brief Library Typedefs 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @brief Font structure used on my LCD libraries 81 | */ 82 | typedef struct { 83 | uint8_t FontWidth; /*!< Font width in pixels */ 84 | uint8_t FontHeight; /*!< Font height in pixels */ 85 | const uint16_t *data; /*!< Pointer to data font data array */ 86 | } TM_FontDef_t; 87 | 88 | /** 89 | * @} 90 | */ 91 | 92 | /** 93 | * @defgroup TM_FONTS_FontVariables 94 | * @brief Library font variables 95 | * @{ 96 | */ 97 | 98 | /** 99 | * @brief 7 x 10 pixels font size structure 100 | */ 101 | extern TM_FontDef_t TM_Font_7x10; 102 | 103 | /** 104 | * @brief 11 x 18 pixels font size structure 105 | */ 106 | extern TM_FontDef_t TM_Font_11x18; 107 | 108 | /** 109 | * @brief 16 x 26 pixels font size structure 110 | */ 111 | extern TM_FontDef_t TM_Font_16x26; 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** 118 | * @} 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /* C++ detection */ 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | 131 | #endif 132 | 133 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341/xprintf.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /* Universal string handler for user console interface (C)ChaN, 2011 */ 3 | /*------------------------------------------------------------------------*/ 4 | 5 | #ifndef _STRFUNC 6 | #define _STRFUNC 7 | 8 | #define _USE_XFUNC_OUT 1 /* 1: Use output functions */ 9 | #define _CR_CRLF 1 /* 1: Convert \n ==> \r\n in the output char */ 10 | 11 | #define _USE_XFUNC_IN 1 /* 1: Use input function */ 12 | #define _LINE_ECHO 1 /* 1: Echo back input chars in xgets function */ 13 | 14 | 15 | #if _USE_XFUNC_OUT 16 | #define xdev_out(func) xfunc_out = (void(*)(unsigned char))(func) 17 | extern void (*xfunc_out)(unsigned char); 18 | void xputc (char c); 19 | void xputs (const char* str); 20 | void xfputs (void (*func)(unsigned char), const char* str); 21 | void xprintf (const char* fmt, ...); 22 | void xsprintf (char* buff, const char* fmt, ...); 23 | void xfprintf (void (*func)(unsigned char), const char* fmt, ...); 24 | void put_dump (const void* buff, unsigned long addr, int len, int width); 25 | #define DW_CHAR sizeof(char) 26 | #define DW_SHORT sizeof(short) 27 | #define DW_LONG sizeof(long) 28 | #endif 29 | 30 | #if _USE_XFUNC_IN 31 | #define xdev_in(func) xfunc_in = (unsigned char(*)(void))(func) 32 | extern unsigned char (*xfunc_in)(void); 33 | int xgets (char* buff, int len); 34 | int xfgets (unsigned char (*func)(void), char* buff, int len); 35 | int xatoi (char** str, long* res); 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341_ucglib/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | spi_ili9341_ucglib 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | 26 | 27 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341_ucglib/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341_ucglib/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | #--- ucglib -------- 8 | CFLAGS += -DUSE_PIN_LIST 9 | CFLAGS += -DUCG_MSG_DRAW_L90BF 10 | # ------------------ 11 | CFLAGS += -DNRF51822 12 | CFLAGS += -DNRF_LOG_USES_UART=1 13 | ASFLAGS += -g 14 | ASMFLAGS += -DBOARD_CUSTOM 15 | ASMFLAGS += -DNRF51822 16 | ASMFLAGS += -DNRF_LOG_USES_UART=1 17 | 18 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf51822_QFAA.ld 19 | 20 | INC_PATHS += -I$(TEMPLATEROOT)/ucglib/csrc 21 | 22 | vpath %.c $(TEMPLATEROOT)/ucglib/csrc 23 | 24 | # object files 25 | 26 | OBJS = system_nrf51.o nrf_log_backend_serial.o nrf_log_frontend.o 27 | OBJS += app_error_weak.o app_error.o app_fifo.o app_util_platform.o nrf_assert.o 28 | OBJS += app_uart_fifo.o nrf_drv_common.o nrf_drv_uart.o 29 | OBJS += nrf_drv_rng.o nrf_drv_spi.o 30 | OBJS += ucg_dev_ic_ili9341.o ucg_dev_tft_240x320_ili9341.o 31 | OBJS += ucg_com_msg_api.o ucg_init.o ucg_dev_msg_api.o ucg_pixel.o ucg_line.o ucg_rotate.o ucg_clip.o ucg_ccs.o 32 | OBJS += ucg_box.o ucg_dev_default_cb.o ucg_font.o ucg_pixel_font_data.o ucg_circle.o ucg_scale.o ucg_polygon.o 33 | OBJS += ucg_nrf51822.o main.o 34 | 35 | # include common make file 36 | 37 | include $(TEMPLATEROOT)/Makefile.common 38 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341_ucglib/ucg_nrf51822.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "nrf_delay.h" 3 | #include "nrf_gpio.h" 4 | #include "boards.h" 5 | #include "sdk_config.h" 6 | #define NRF_LOG_MODULE_NAME "PCBREFLUX SPI" 7 | #include "nrf_log.h" 8 | #include "nrf_log_ctrl.h" 9 | #include "nrf_drv_spi.h" 10 | #include "app_uart.h" 11 | #include "app_error.h" 12 | #include "ucg_nrf51822.h" 13 | 14 | extern nrf_drv_spi_t *nrf51822_spi_instance; 15 | 16 | 17 | int16_t ucg_com_nrf51822_generic_HW_SPI(ucg_t *ucg, int16_t msg, uint16_t arg, uint8_t *data) { 18 | 19 | switch(msg) { 20 | case UCG_COM_MSG_POWER_UP: 21 | /* "data" is a pointer to ucg_com_info_t structure with the following information: */ 22 | /* ((ucg_com_info_t *)data)->serial_clk_speed value in nanoseconds */ 23 | /* ((ucg_com_info_t *)data)->parallel_clk_speed value in nanoseconds */ 24 | 25 | /* setup pins */ 26 | nrf_gpio_cfg_output(ucg->pin_list[UCG_PIN_CD]); 27 | nrf_gpio_pin_write(ucg->pin_list[UCG_PIN_CD], 1); // dc 1 = data, 0 = control 28 | if ( ucg->pin_list[UCG_PIN_CS] != UCG_PIN_VAL_NONE ) { 29 | nrf_gpio_cfg_output(ucg->pin_list[UCG_PIN_CS]); 30 | nrf_gpio_pin_write(ucg->pin_list[UCG_PIN_CS], 1); // cs off 31 | } 32 | if ( ucg->pin_list[UCG_PIN_RST] != UCG_PIN_VAL_NONE ) { 33 | nrf_gpio_cfg_output(ucg->pin_list[UCG_PIN_RST]); 34 | nrf_gpio_pin_write(ucg->pin_list[UCG_PIN_RST], 1); // no reset 35 | } 36 | 37 | break; 38 | case UCG_COM_MSG_POWER_DOWN: 39 | break; 40 | case UCG_COM_MSG_DELAY: 41 | nrf_delay_us(arg); 42 | break; 43 | case UCG_COM_MSG_CHANGE_RESET_LINE: 44 | if ( ucg->pin_list[UCG_PIN_RST] != UCG_PIN_VAL_NONE ) 45 | nrf_gpio_pin_write(ucg->pin_list[UCG_PIN_RST], arg); 46 | break; 47 | case UCG_COM_MSG_CHANGE_CS_LINE: 48 | if ( ucg->pin_list[UCG_PIN_CS] != UCG_PIN_VAL_NONE ) 49 | nrf_gpio_pin_write(ucg->pin_list[UCG_PIN_CS], arg); 50 | break; 51 | case UCG_COM_MSG_CHANGE_CD_LINE: 52 | nrf_gpio_pin_write(ucg->pin_list[UCG_PIN_CD], arg); 53 | break; 54 | case UCG_COM_MSG_SEND_BYTE: 55 | nrf_drv_spi_transfer(nrf51822_spi_instance,(uint8_t *)&arg,1,NULL,0); 56 | break; 57 | case UCG_COM_MSG_REPEAT_1_BYTE: 58 | while( arg > 0 ) { 59 | nrf_drv_spi_transfer(nrf51822_spi_instance,data,1,NULL,0); 60 | arg--; 61 | } 62 | break; 63 | case UCG_COM_MSG_REPEAT_2_BYTES: 64 | while( arg > 0 ) { 65 | nrf_drv_spi_transfer(nrf51822_spi_instance,data,2,NULL,0); 66 | arg--; 67 | } 68 | break; 69 | case UCG_COM_MSG_REPEAT_3_BYTES: 70 | while( arg > 0 ) { 71 | nrf_drv_spi_transfer(nrf51822_spi_instance,data,3,NULL,0); 72 | arg--; 73 | } 74 | break; 75 | case UCG_COM_MSG_SEND_STR: 76 | nrf_drv_spi_transfer(nrf51822_spi_instance,data,arg,NULL,0); 77 | break; 78 | case UCG_COM_MSG_SEND_CD_DATA_SEQUENCE: 79 | while(arg > 0) { 80 | if ( *data != 0 ) { 81 | if ( *data == 1 ) { 82 | nrf_gpio_pin_write(ucg->pin_list[UCG_PIN_CD], 0); 83 | } else { 84 | nrf_gpio_pin_write(ucg->pin_list[UCG_PIN_CD], 1); 85 | } 86 | } 87 | data++; 88 | nrf_drv_spi_transfer(nrf51822_spi_instance,data,1,NULL,0); 89 | data++; 90 | arg--; 91 | } 92 | break; 93 | } 94 | return 1; 95 | } 96 | 97 | -------------------------------------------------------------------------------- /nRF51822/spi_ili9341_ucglib/ucg_nrf51822.h: -------------------------------------------------------------------------------- 1 | #ifndef _UCG_NRF51822_H 2 | #define _UCG_NRF51822_H 3 | 4 | //adjust this path: 5 | #include "ucg.h" 6 | 7 | //main com function. read on... 8 | int16_t ucg_com_nrf51822_generic_HW_SPI(ucg_t *ucg, int16_t msg, uint16_t arg, uint8_t *data); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /nRF51822/spi_max6675/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | spi_max6675 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | org.eclipse.cdt.core.ccnature 26 | 27 | 28 | -------------------------------------------------------------------------------- /nRF51822/spi_max6675/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /nRF51822/spi_max6675/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF51822 8 | CFLAGS += -DNRF_LOG_USES_UART=1 9 | ASFLAGS += -g 10 | ASMFLAGS += -DBOARD_CUSTOM 11 | ASMFLAGS += -DNRF51822 12 | ASMFLAGS += -DNRF_LOG_USES_UART=1 13 | 14 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf51822_QFAA.ld 15 | 16 | # object files 17 | 18 | OBJS = system_nrf51.o nrf_log_backend_serial.o nrf_log_frontend.o 19 | OBJS += app_error_weak.o app_error.o app_fifo.o app_util_platform.o nrf_assert.o app_uart_fifo.o nrf_drv_common.o nrf_drv_uart.o 20 | OBJS += nrf_drv_spi.o nrf_drv_clock.o nrf_drv_rtc.o 21 | OBJS += max6675.o main.o 22 | 23 | # include common make file 24 | 25 | include $(TEMPLATEROOT)/Makefile.common 26 | -------------------------------------------------------------------------------- /nRF51822/spi_max6675/custom_board.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | #ifndef BLE_TEST_BOARD_H 13 | #define BLE_TEST_BOARD_H 14 | 15 | // LEDs definitions for PCA10028 16 | #define LEDS_NUMBER 5 17 | 18 | #define LED_START 18 19 | #define LED_1 18 20 | #define LED_2 19 21 | #define LED_3 20 22 | #define LED_4 21 23 | #define LED_5 22 24 | #define LED_STOP 22 25 | 26 | #define LEDS_LIST { LED_1, LED_2, LED_3, LED_4, LED_5 } 27 | 28 | #define BSP_LED_0 LED_1 29 | #define BSP_LED_1 LED_2 30 | #define BSP_LED_2 LED_3 31 | #define BSP_LED_3 LED_4 32 | #define BSP_LED_4 LED_5 33 | 34 | #define BSP_LED_0_MASK (1< CPTX 63 | #define TX_PIN_NUMBER 2 // -> CPRX 64 | #define CTS_PIN_NUMBER 7 // -> CPRTS 65 | #define RTS_PIN_NUMBER 8 // -> CPCTS 66 | #define HWFC false 67 | #define UART0_CONFIG_BAUDRATE UART_BAUDRATE_BAUDRATE_Baud115200 68 | 69 | #define SPIS_MISO_PIN 28 // SPI MISO signal. 70 | #define SPIS_CSN_PIN 12 // SPI CSN signal. 71 | #define SPIS_MOSI_PIN 25 // SPI MOSI signal. 72 | #define SPIS_SCK_PIN 29 // SPI SCK signal. 73 | 74 | #define SPIM0_SCK_PIN 3 /**< SPI clock GPIO pin number. */ 75 | #define SPIM0_MOSI_PIN 5 /**< SPI Master Out Slave In GPIO pin number. */ 76 | #define SPIM0_MISO_PIN 4 /**< SPI Master In Slave Out GPIO pin number. */ 77 | #define SPIM0_SS_PIN 9 /**< SPI Slave Select GPIO pin number. */ 78 | 79 | #define SPIM1_SCK_PIN 15 /**< SPI clock GPIO pin number. */ 80 | #define SPIM1_MOSI_PIN 12 /**< SPI Master Out Slave In GPIO pin number. */ 81 | #define SPIM1_MISO_PIN 14 /**< SPI Master In Slave Out GPIO pin number. */ 82 | #define SPIM1_SS_PIN 13 /**< SPI Slave Select GPIO pin number. */ 83 | 84 | // serialization APPLICATION board 85 | #define SER_CONN_CHIP_RESET_PIN 30 // Pin used to reset connectivity chip 86 | 87 | #define SER_APP_RX_PIN RX_PIN_NUMBER // UART RX pin number. 88 | #define SER_APP_TX_PIN TX_PIN_NUMBER // UART TX pin number. 89 | #define SER_APP_CTS_PIN CTS_PIN_NUMBER // UART Clear To Send pin number. 90 | #define SER_APP_RTS_PIN RTS_PIN_NUMBER // UART Request To Send pin number. 91 | 92 | #define SER_APP_SPIM0_SCK_PIN 29 // SPI clock GPIO pin number. 93 | #define SER_APP_SPIM0_MOSI_PIN 25 // SPI Master Out Slave In GPIO pin number 94 | #define SER_APP_SPIM0_MISO_PIN 28 // SPI Master In Slave Out GPIO pin number 95 | #define SER_APP_SPIM0_SS_PIN 12 // SPI Slave Select GPIO pin number 96 | #define SER_APP_SPIM0_RDY_PIN 14 // SPI READY GPIO pin number 97 | #define SER_APP_SPIM0_REQ_PIN 13 // SPI REQUEST GPIO pin number 98 | 99 | // serialization CONNECTIVITY board 100 | #define SER_CON_RX_PIN RX_PIN_NUMBER // UART RX pin number. 101 | #define SER_CON_TX_PIN TX_PIN_NUMBER // UART TX pin number. 102 | #define SER_CON_CTS_PIN CTS_PIN_NUMBER // UART Clear To Send pin number. Not used if HWFC is set to false. 103 | #define SER_CON_RTS_PIN RTS_PIN_NUMBER // UART Request To Send pin number. Not used if HWFC is set to false. 104 | 105 | 106 | #define SER_CON_SPIS_SCK_PIN 29 // SPI SCK signal. 107 | #define SER_CON_SPIS_MOSI_PIN 25 // SPI MOSI signal. 108 | #define SER_CON_SPIS_MISO_PIN 28 // SPI MISO signal. 109 | #define SER_CON_SPIS_CSN_PIN 12 // SPI CSN signal. 110 | #define SER_CON_SPIS_RDY_PIN 14 // SPI READY GPIO pin number. 111 | #define SER_CON_SPIS_REQ_PIN 13 // SPI REQUEST GPIO pin number. 112 | 113 | // Arduino board mappings 114 | #define ARDUINO_SCL_PIN 7 // SCL signal pin 115 | #define ARDUINO_SDA_PIN 30 // SDA signal pin 116 | #define ARDUINO_AREF_PIN 0 // Aref pin 117 | #define ARDUINO_13_PIN 29 // Digital pin 13 118 | #define ARDUINO_12_PIN 28 // Digital pin 12 119 | #define ARDUINO_11_PIN 25 // Digital pin 11 120 | #define ARDUINO_10_PIN 24 // Digital pin 10 121 | #define ARDUINO_9_PIN 23 // Digital pin 9 122 | #define ARDUINO_8_PIN 20 // Digital pin 8 123 | 124 | #define ARDUINO_7_PIN 19 // Digital pin 7 125 | #define ARDUINO_6_PIN 18 // Digital pin 6 126 | #define ARDUINO_5_PIN 17 // Digital pin 5 127 | #define ARDUINO_4_PIN 16 // Digital pin 4 128 | #define ARDUINO_3_PIN 15 // Digital pin 3 129 | #define ARDUINO_2_PIN 14 // Digital pin 2 130 | #define ARDUINO_1_PIN 13 // Digital pin 1 131 | #define ARDUINO_0_PIN 12 // Digital pin 0 132 | 133 | #define ARDUINO_A0_PIN 1 // Analog channel 0 134 | #define ARDUINO_A1_PIN 2 // Analog channel 1 135 | #define ARDUINO_A2_PIN 3 // Analog channel 2 136 | #define ARDUINO_A3_PIN 4 // Analog channel 3 137 | #define ARDUINO_A4_PIN 5 // Analog channel 4 138 | #define ARDUINO_A5_PIN 6 // Analog channel 5 139 | 140 | // Low frequency clock source to be used by the SoftDevice 141 | /* 142 | #define NRF_CLOCK_LFCLKSRC NRF_CLOCK_LFCLKSRC_XTAL_20_PPM 143 | */ 144 | #define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_SYNTH, \ 145 | .rc_ctiv = 0, \ 146 | .rc_temp_ctiv = 0, \ 147 | .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} 148 | 149 | #endif // BLE_TEST_BOARD_H 150 | -------------------------------------------------------------------------------- /nRF51822/spi_max6675/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | /** @file main.c (changed by pcbreflux) 17 | * @brief SPI Example Application main file. 18 | * 19 | */ 20 | #include 21 | #include "nrf_delay.h" 22 | #include "nrf_gpio.h" 23 | #include "boards.h" 24 | #include "sdk_config.h" 25 | #define NRF_LOG_MODULE_NAME "PCBREFLUX SPI" 26 | #include "nrf_log.h" 27 | #include "nrf_log_ctrl.h" 28 | #include "nrf_drv_spi.h" 29 | #include "nrf_drv_clock.h" 30 | #include "nrf_drv_rtc.h" 31 | #include "app_uart.h" 32 | #include "app_error.h" 33 | #include "max6675.h" 34 | 35 | // see nrf_drv_config.h for defining RTC1 36 | #define RTC1_PRESCALE 8 37 | 38 | // Softdevice S110, S120, S130 blocks RTC0 39 | const nrf_drv_rtc_t rtc1 = NRF_DRV_RTC_INSTANCE(1); /**< Declaring an instance of nrf_drv_rtc for RTC1. */ 40 | 41 | // defining SPI0 42 | const nrf_drv_spi_t my_spi_0 = NRF_DRV_SPI_INSTANCE(0); /**< Declaring an instance of nrf_drv_spi for SPI0. */ 43 | 44 | const uint32_t led_pin1 = 19; 45 | 46 | static max6675_config_t max6675_config = MAX6675_DEFAULT_CONFIG; 47 | static uint32_t pos=0; 48 | 49 | /** @brief Function initialization and configuration of RTC driver instance. 50 | */ 51 | static void gpio_config() { 52 | // Configure LED-pin as outputs and clear. 53 | NRF_LOG_DEBUG("nrf_gpio_cfg_output %d\n\r",led_pin1); 54 | nrf_gpio_cfg_output(led_pin1); 55 | nrf_gpio_pin_clear(led_pin1); 56 | } 57 | 58 | /** @brief Function initialization and configuration of RTC driver instance. 59 | */ 60 | static void spi_config(max6675_config_t *max6675_config) { 61 | ret_code_t err_code; 62 | 63 | nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG; 64 | 65 | NRF_LOG_DEBUG("spi config %d %d %d\n\r",max6675_config->miso_pin,max6675_config->sck_pin,max6675_config->cs_pin); 66 | spi_config.sck_pin = max6675_config->sck_pin; 67 | spi_config.mosi_pin = 0xFF; // not used 68 | spi_config.miso_pin = max6675_config->miso_pin; 69 | spi_config.ss_pin = 0xFF; // max6675 need Conversion Time 220ms, so we set it external 70 | //spi_config.frequency = NRF_DRV_SPI_FREQ_125K; // tCP = 100ns see MAX7219/MAX7221 Datasheet TIMING CHARACTERISTICS 71 | spi_config.frequency = NRF_DRV_SPI_FREQ_8M; // tCP = 100ns see MAX7219/MAX7221 Datasheet TIMING CHARACTERISTICS 72 | spi_config.mode = NRF_DRV_SPI_MODE_0; // SCK active high, sample on leading edge of clock. 73 | spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST; 74 | 75 | err_code = nrf_drv_spi_init(&my_spi_0,&spi_config,NULL); 76 | APP_ERROR_CHECK(err_code); 77 | 78 | } 79 | 80 | static void rtc1_handler(nrf_drv_rtc_int_type_t int_type) { 81 | // uint32_t err_code; 82 | 83 | NRF_LOG_DEBUG("rtc1_handler %d %u\n\r",int_type,pos); 84 | if (int_type == NRF_DRV_RTC_INT_COMPARE0) { // Interrupt from COMPARE0 event. 85 | uint16_t temp; 86 | nrf_gpio_pin_toggle(led_pin1); 87 | if (pos%2==0) { 88 | max6675_prepare(&max6675_config); 89 | } else { 90 | temp=max6675_readcelsius(&max6675_config); 91 | NRF_LOG_INFO("rtc1_handler temp \x1B[1;32m%u\x1B[0m,\x1B[1;31m%d\x1B[0m \r",temp>>2,(temp&0x0003)*25); 92 | } 93 | nrf_drv_rtc_int_enable(&rtc1, RTC_CHANNEL_INT_MASK(0)); 94 | nrf_drv_rtc_counter_clear(&rtc1); 95 | 96 | 97 | } 98 | pos++; 99 | } 100 | 101 | /** @brief Function starting the internal LFCLK XTAL oscillator. 102 | */ 103 | static void lfclk_config(void) { 104 | ret_code_t err_code = nrf_drv_clock_init(); 105 | APP_ERROR_CHECK(err_code); 106 | 107 | nrf_drv_clock_lfclk_request(NULL); 108 | } 109 | 110 | /** @brief Function initialization and configuration of RTC driver instance. 111 | */ 112 | static void rtc_config(void) { 113 | uint32_t err_code; 114 | 115 | NRF_LOG_DEBUG("rtc config %d\n\r",RTC1_PRESCALE); 116 | //Initialize RTC instance 117 | nrf_drv_rtc_config_t rtc_config = NRF_DRV_RTC_DEFAULT_CONFIG; 118 | rtc_config.prescaler = RTC1_PRESCALE; 119 | 120 | err_code = nrf_drv_rtc_init(&rtc1, &rtc_config, rtc1_handler); 121 | APP_ERROR_CHECK(err_code); 122 | 123 | //Disable tick event & interrupt 124 | nrf_drv_rtc_tick_enable(&rtc1,false); 125 | 126 | //Set compare channel 0 to trigger interrupt after 0.5s 127 | err_code = nrf_drv_rtc_cc_set(&rtc1,0,RTC_DEFAULT_CONFIG_FREQUENCY/RTC1_PRESCALE/4,true); // 500ms 128 | APP_ERROR_CHECK(err_code); 129 | 130 | //Power on RTC instance 131 | nrf_drv_rtc_enable(&rtc1); 132 | } 133 | 134 | /** 135 | * @brief Function for application main entry. 136 | */ 137 | int main(void) { 138 | 139 | max6675_config.spi_instance = &my_spi_0; 140 | 141 | APP_ERROR_CHECK(NRF_LOG_INIT(NULL)); 142 | 143 | NRF_LOG_INFO("start spi MAX6675\n\r"); 144 | 145 | // setup 146 | gpio_config(max6675_config.cs_pin); // Configure GPIO pins. 147 | spi_config(&max6675_config); 148 | max6675_init(&max6675_config); 149 | lfclk_config(); 150 | rtc_config(); 151 | 152 | // loop 153 | while (true) { 154 | // Enter System ON sleep mode 155 | __WFE(); 156 | // Make sure any pending events are cleared 157 | __SEV(); 158 | __WFE(); 159 | } 160 | } 161 | 162 | 163 | /** @} */ 164 | -------------------------------------------------------------------------------- /nRF51822/spi_max6675/max6675.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | #include 16 | #include "app_error.h" 17 | #include "nrf_drv_spi.h" 18 | #include "nrf_log.h" 19 | #include "nrf_log_ctrl.h" 20 | #include "boards.h" 21 | #include "max6675.h" 22 | 23 | void max6675_init(max6675_config_t const * const max6675_config) { 24 | NRF_LOG_DEBUG("max6675_init %d\n\r",max6675_config->cs_pin); 25 | nrf_gpio_cfg_output(max6675_config->cs_pin); 26 | nrf_gpio_pin_set(max6675_config->cs_pin); 27 | } 28 | 29 | void max6675_prepare(max6675_config_t const * const max6675_config) { 30 | NRF_LOG_DEBUG("max6675_prepare\n\r"); 31 | nrf_gpio_pin_clear(max6675_config->cs_pin); 32 | } 33 | 34 | uint16_t max6675_readcelsius(max6675_config_t const * const max6675_config) { 35 | ret_code_t err_code; 36 | uint8_t outbuffer[2]; 37 | uint16_t temp; 38 | 39 | //NRF_LOG_INFO("max6675_readcelsius\n\r"); 40 | err_code = nrf_drv_spi_transfer(max6675_config->spi_instance,NULL,0,outbuffer,2); 41 | APP_ERROR_CHECK(err_code); 42 | nrf_gpio_pin_set(max6675_config->cs_pin); 43 | 44 | //NRF_LOG_INFO("max6675_readcelsius out=%d %d\n\r",outbuffer[0],outbuffer[1]); 45 | temp = ((uint16_t)outbuffer[0]<<8)|((uint16_t)outbuffer[1]); 46 | temp = temp>>3; 47 | 48 | NRF_LOG_DEBUG("max6675_readcelsius out=%d\n\r",temp); 49 | 50 | return temp; 51 | } 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /nRF51822/spi_max6675/max6675.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | #ifndef MAX6675_H 17 | #define MAX6675_H 18 | /** 19 | * @brief UART header file. 20 | * 21 | * This file contains the defining code for a application using UART. 22 | * 23 | */ 24 | 25 | #define MAX6675_DEFAULT_CONFIG { \ 26 | .miso_pin = SPIM0_MISO_PIN, \ 27 | .sck_pin = SPIM0_SCK_PIN, \ 28 | .cs_pin = SPIM0_SS_PIN, \ 29 | .spi_instance = NULL \ 30 | } 31 | 32 | /**@brief MAX6675 configuration structure.*/ 33 | typedef struct { 34 | uint32_t miso_pin; /* Pin number for MISO input. */ 35 | uint32_t sck_pin; /* Pin number for CLK output. */ 36 | uint32_t cs_pin; /* Pin number for client select/Load output. */ 37 | nrf_drv_spi_t const *spi_instance; /* ptr to SPI instance */ 38 | } max6675_config_t; 39 | 40 | /**@brief Function for initialize max6675. 41 | * 42 | * @param[in] max6675_config Pointer to MAX6675 configuration structure. 43 | */ 44 | void max6675_init(max6675_config_t const * const max6675_config); 45 | 46 | /**@brief Function for prepare reading max6675. 47 | * 48 | * @param[in] max6675_config Pointer to MAX6675 configuration structure. 49 | */ 50 | void max6675_prepare(max6675_config_t const * const max6675_config); 51 | 52 | /**@brief Function for reading max6675 value in 0.25 times degrees celsius. 53 | * 54 | * @param[in] max6675_config Pointer to MAX6675 configuration structure. 55 | * 56 | * @return value in 0.25 times degrees celsius. 57 | */ 58 | uint16_t max6675_readcelsius(max6675_config_t const * const max6675_config); 59 | 60 | #endif // MAX6675_H 61 | -------------------------------------------------------------------------------- /nRF51822/spi_max7221/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF51822 8 | CFLAGS += -DNRF_LOG_USES_UART=1 9 | ASFLAGS += -g 10 | ASMFLAGS += -DBOARD_CUSTOM 11 | ASMFLAGS += -DNRF51822 12 | ASMFLAGS += -DNRF_LOG_USES_UART=1 13 | 14 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf51822_QFAA.ld 15 | 16 | # object files 17 | 18 | OBJS = system_nrf51.o nrf_log_backend_serial.o nrf_log_frontend.o 19 | OBJS += app_error_weak.o app_error.o app_fifo.o app_util_platform.o nrf_assert.o app_uart_fifo.o nrf_drv_common.o nrf_drv_uart.o 20 | OBJS += nrf_drv_spi.o 21 | OBJS += max7221.o main.o 22 | 23 | # include common make file 24 | 25 | include $(TEMPLATEROOT)/Makefile.common 26 | -------------------------------------------------------------------------------- /nRF51822/spi_max7221/flash.txt: -------------------------------------------------------------------------------- 1 | make flash 2 | -------------------------------------------------------------------------------- /nRF51822/spi_max7221/max7221.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | #include "app_error.h" 17 | #include "nrf_drv_spi.h" 18 | #include "max7221.h" 19 | #include "nrf_log.h" 20 | #include "nrf_log_ctrl.h" 21 | #include "boards.h" 22 | #include "glcdfont.h" 23 | 24 | #define MAX7221_OUT_BUF_SIZE 256 /**< SPI out buffer size. */ 25 | static uint8_t max7221_outbuffer[MAX7221_OUT_BUF_SIZE]; 26 | static uint8_t max7221_device_cnt=1; 27 | 28 | /** 29 | * @brief Function for uart_error_handle uart error handling. 30 | */ 31 | void max7221_init(nrf_drv_spi_t const * const spi_instance, uint8_t device_cnt) { 32 | uint8_t devpos; 33 | 34 | if (device_cnt<(MAX7221_OUT_BUF_SIZE/2)) { 35 | max7221_device_cnt = device_cnt; 36 | } 37 | 38 | for (devpos=0;devpos9) { 74 | number='*'; 75 | } 76 | max7221_writechar(spi_instance,devnum,number+'0'); 77 | } 78 | 79 | /** 80 | * @brief Function for uart_error_handle uart error handling. 81 | */ 82 | void max7221_writechar(nrf_drv_spi_t const * const spi_instance,uint8_t devnum,uint8_t ascii) { 83 | uint8_t bitpos=0; 84 | uint16_t fontpos=0; 85 | 86 | fontpos = ascii*5; 87 | max7221_clear(spi_instance,devnum); 88 | for(bitpos=0;bitpos<5;bitpos++) { 89 | max7221_transbuffer(spi_instance,devnum,MAX7221_CON_DIGIT0+bitpos+2,font[fontpos+bitpos]<<1); 90 | } 91 | } 92 | 93 | 94 | void max7221_transbuffer(nrf_drv_spi_t const * const spi_instance,uint8_t devnum,uint8_t code,uint8_t value) { 95 | ret_code_t err_code; 96 | uint8_t devpos; 97 | uint8_t device; 98 | uint32_t bufsize; 99 | 100 | if (devnum<=max7221_device_cnt) { 101 | device = devnum; 102 | } else { 103 | device = 1; 104 | } 105 | bufsize=max7221_device_cnt*2; 106 | for (devpos=0;devpos. * 14 | */ 15 | 16 | #ifndef MAX7221_H 17 | #define MAX7221_H 18 | /** 19 | * @brief UART header file. 20 | * 21 | * This file contains the defining code for a application using UART. 22 | * 23 | */ 24 | 25 | #define MAX7221_CS_PIN 28 /**< SPI Slave Select GPIO pin number. */ 26 | 27 | #define MAX7221_DEFAULT_CONFIG { \ 28 | .mosi_pin = SPIM0_MOSI_PIN, \ 29 | .sck_pin = SPIM0_SCK_PIN, \ 30 | .cs_pin = SPIM0_SS_PIN \ 31 | } 32 | 33 | /**@brief MAX7221 configuration structure.*/ 34 | typedef struct { 35 | uint32_t mosi_pin; /**< Pin number for MOSI output. */ 36 | uint32_t sck_pin; /**< Pin number for CLK output. */ 37 | uint32_t cs_pin; /**< Pin number for client select/Load output. */ 38 | } max7221_config_t; 39 | 40 | // see MAX7219/MAX7221 Datasheet Table 2. Register Address Map 41 | enum max7221_op_t { 42 | MAX7221_CON_NOOP = 0, 43 | MAX7221_CON_DIGIT0 = 1, 44 | MAX7221_CON_DIGIT1 = 2, 45 | MAX7221_CON_DIGIT2 = 3, 46 | MAX7221_CON_DIGIT3 = 4, 47 | MAX7221_CON_DIGIT4 = 5, 48 | MAX7221_CON_DIGIT5 = 6, 49 | MAX7221_CON_DIGIT6 = 7, 50 | MAX7221_CON_DIGIT7 = 8, 51 | MAX7221_CON_DECODEMODE = 9, 52 | MAX7221_CON_INTENSITY = 10, 53 | MAX7221_CON_SCANLIMIT = 11, 54 | MAX7221_CON_SHUTDOWN = 12, 55 | MAX7221_CON_DISPLAYTEST = 15 56 | }; 57 | 58 | /** 59 | * @brief Function for uart_error_handle uart error handling. 60 | */ 61 | void max7221_init(nrf_drv_spi_t const * const spi_instance,uint8_t devnum); 62 | 63 | void max7221_set(nrf_drv_spi_t const * const spi_instance,uint8_t devnum,uint8_t pos,uint32_t value); 64 | 65 | void max7221_clear(nrf_drv_spi_t const * const spi_instance,uint8_t devnum); 66 | 67 | void max7221_writenumber(nrf_drv_spi_t const * const spi_instance,uint8_t devnum,uint8_t number); 68 | 69 | void max7221_writechar(nrf_drv_spi_t const * const spi_instance,uint8_t devnum,uint8_t ascii); 70 | 71 | void max7221_transbuffer(nrf_drv_spi_t const * const spi_instance,uint8_t devnum,uint8_t code,uint8_t value); 72 | 73 | #endif // MAX7221_H 74 | -------------------------------------------------------------------------------- /nRF51822/timer_blinky/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | ASFLAGS += -g 7 | 8 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf51822_QFAA.ld 9 | 10 | # object files 11 | 12 | OBJS = system_nrf51.o app_error.o app_util_platform.o nrf_drv_clock.o nrf_drv_common.o nrf_drv_timer.o 13 | OBJS += timer_blinky.o 14 | 15 | # include common make file 16 | 17 | include $(TEMPLATEROOT)/Makefile.common 18 | -------------------------------------------------------------------------------- /nRF51822/timer_blinky/flash.txt: -------------------------------------------------------------------------------- 1 | openocd -d3 -f ../openocd.cfg 2 | telnet 127.0.0.1 4444 3 | reset halt 4 | nrf51 mass_erase 5 | ##flash banks 6 | halt 7 | program /home/pcbreflux/nordic/nordic.git/nRF51822/timer_blinky/_build/timer_blinky.hex verify 8 | reset 9 | 10 | -------------------------------------------------------------------------------- /nRF51822/timer_blinky/nrf_drv_config.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef NRF_DRV_CONFIG_H 14 | #define NRF_DRV_CONFIG_H 15 | 16 | /** 17 | * Provide a non-zero value here in applications that need to use several 18 | * peripherals with the same ID that are sharing certain resources 19 | * (for example, SPI0 and TWI0). Obviously, such peripherals cannot be used 20 | * simultaneously. Therefore, this definition allows to initialize the driver 21 | * for another peripheral from a given group only after the previously used one 22 | * is uninitialized. Normally, this is not possible, because interrupt handlers 23 | * are implemented in individual drivers. 24 | * This functionality requires a more complicated interrupt handling and driver 25 | * initialization, hence it is not always desirable to use it. 26 | */ 27 | #define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 28 | 29 | /* CLOCK */ 30 | #define CLOCK_ENABLED 1 31 | #define CLOCK_CONFIG_XTAL_FREQ NRF_CLOCK_XTALFREQ_Default 32 | #define CLOCK_CONFIG_LF_SRC NRF_CLOCK_LFCLK_Xtal 33 | #define CLOCK_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 34 | 35 | /* TIMER */ 36 | #define TIMER0_ENABLED 0 37 | 38 | #if (TIMER0_ENABLED == 1) 39 | #define TIMER0_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz 40 | #define TIMER0_CONFIG_MODE TIMER_MODE_MODE_Timer 41 | #define TIMER0_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_32Bit 42 | #define TIMER0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 43 | 44 | #define TIMER0_INSTANCE_INDEX 0 45 | #endif 46 | 47 | #define TIMER1_ENABLED 1 48 | 49 | #if (TIMER1_ENABLED == 1) 50 | #define TIMER1_CONFIG_FREQUENCY NRF_TIMER_FREQ_31250Hz 51 | #define TIMER1_CONFIG_MODE TIMER_MODE_MODE_Timer 52 | #define TIMER1_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit 53 | #define TIMER1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 54 | 55 | #define TIMER1_INSTANCE_INDEX (TIMER0_ENABLED) 56 | #endif 57 | 58 | #define TIMER2_ENABLED 0 59 | 60 | #if (TIMER2_ENABLED == 1) 61 | #define TIMER2_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz 62 | #define TIMER2_CONFIG_MODE TIMER_MODE_MODE_Timer 63 | #define TIMER2_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit 64 | #define TIMER2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 65 | 66 | #define TIMER2_INSTANCE_INDEX (TIMER1_ENABLED+TIMER0_ENABLED) 67 | #endif 68 | 69 | #define TIMER3_ENABLED 0 70 | 71 | #if (TIMER3_ENABLED == 1) 72 | #define TIMER3_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz 73 | #define TIMER3_CONFIG_MODE TIMER_MODE_MODE_Timer 74 | #define TIMER3_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit 75 | #define TIMER3_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 76 | 77 | #define TIMER3_INSTANCE_INDEX (TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED) 78 | #endif 79 | 80 | #define TIMER4_ENABLED 0 81 | 82 | #if (TIMER4_ENABLED == 1) 83 | #define TIMER4_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz 84 | #define TIMER4_CONFIG_MODE TIMER_MODE_MODE_Timer 85 | #define TIMER4_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit 86 | #define TIMER4_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 87 | 88 | #define TIMER4_INSTANCE_INDEX (TIMER3_ENABLED+TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED) 89 | #endif 90 | 91 | #define TIMER_COUNT (TIMER0_ENABLED + TIMER1_ENABLED + TIMER2_ENABLED + TIMER3_ENABLED + TIMER4_ENABLED) 92 | #include "nrf_drv_config_validation.h" 93 | 94 | #endif // NRF_DRV_CONFIG_H 95 | -------------------------------------------------------------------------------- /nRF51822/timer_blinky/timer_blinky.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file timer_blinky.c (changed by pcbreflux) 14 | * @brief Blinky Example Application main file. 15 | * 16 | */ 17 | #include 18 | #include "nrf_delay.h" 19 | #include "nrf_gpio.h" 20 | #include "nrf_drv_clock.h" 21 | #include "nrf_drv_timer.h" 22 | #include "app_error.h" 23 | 24 | // see nrf_drv_config.h for defining TIMER1 25 | // Softdevice S110, S120, S130 blocks TIMER0 26 | const nrf_drv_timer_t mytimer1 = NRF_DRV_TIMER_INSTANCE(1); /**< Declaring an instance of nrf_drv_timer for TIMER1. */ 27 | 28 | const uint32_t led_pin1 = 19; 29 | static uint32_t tick_pos = 0; 30 | 31 | /** @brief Function initialization and configuration of GPIO. 32 | */ 33 | static void gpio_config(void) { 34 | // Configure LED-pin as outputs and clear. 35 | nrf_gpio_cfg_output(led_pin1); 36 | nrf_gpio_pin_clear(led_pin1); 37 | } 38 | 39 | /** @brief Function for timer events. 40 | */ 41 | static void timer1_handler(nrf_timer_event_t event_type, void* p_context) { 42 | // uint32_t err_code; 43 | 44 | if (event_type == NRF_TIMER_EVENT_COMPARE0) { // Interrupt from COMPARE0 event. 45 | tick_pos++; 46 | if (tick_pos==1) { 47 | nrf_gpio_pin_set(led_pin1); 48 | } else if (tick_pos==2) { 49 | nrf_gpio_pin_clear(led_pin1); 50 | } else if (tick_pos==10) { 51 | tick_pos=0; 52 | } 53 | } 54 | } 55 | 56 | /** @brief Function starting the HFCLK oscillator. 57 | */ 58 | static void hfclk_config(void) { 59 | ret_code_t err_code = nrf_drv_clock_init(); 60 | APP_ERROR_CHECK(err_code); 61 | 62 | nrf_drv_clock_hfclk_request(NULL); 63 | } 64 | 65 | /** @brief Function initialization and configuration of timer driver instance. 66 | */ 67 | static void timer_config(void) { 68 | uint32_t time_in_ms = 1000; //Time(in miliseconds) between consecutive compare events. 69 | // see 70 | uint32_t time2ticks; 71 | uint32_t err_code; 72 | 73 | err_code = nrf_drv_timer_init(&mytimer1, NULL, timer1_handler); 74 | APP_ERROR_CHECK(err_code); 75 | 76 | time2ticks = nrf_drv_timer_ms_to_ticks(&mytimer1, time_in_ms); 77 | 78 | /* 79 | |----| |----| 80 | | | | | 81 | ____| |______________________..._____| |____... 82 | 1s 1s 8s 1s 1s 83 | */ 84 | nrf_drv_timer_extended_compare(&mytimer1, NRF_TIMER_CC_CHANNEL0, time2ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true); 85 | 86 | nrf_drv_timer_enable(&mytimer1); 87 | } 88 | 89 | /** 90 | * @brief Function for application main entry. 91 | */ 92 | int main(void) { 93 | 94 | // setup 95 | gpio_config(); 96 | hfclk_config(); 97 | timer_config(); 98 | 99 | // loop 100 | while (true) { 101 | // Enter System ON sleep mode 102 | __WFE(); 103 | // Make sure any pending events are cleared 104 | __SEV(); 105 | __WFE(); 106 | } 107 | } 108 | 109 | 110 | /** @} */ 111 | -------------------------------------------------------------------------------- /nRF51822/timer_servo/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | ASFLAGS += -g 7 | 8 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf51822_QFAA.ld 9 | 10 | # object files 11 | 12 | OBJS = system_nrf51.o app_error.o app_util_platform.o nrf_drv_clock.o nrf_drv_common.o nrf_drv_timer.o 13 | OBJS += timer_servo.o 14 | 15 | # include common make file 16 | 17 | include $(TEMPLATEROOT)/Makefile.common 18 | -------------------------------------------------------------------------------- /nRF51822/timer_servo/flash.txt: -------------------------------------------------------------------------------- 1 | openocd -d3 -f ../openocd.cfg 2 | telnet 127.0.0.1 4444 3 | reset halt 4 | nrf51 mass_erase 5 | ##flash banks 6 | halt 7 | program /home/pcbreflux/nordic/nordic.git/nRF51822/timer_servo/_build/timer_servo.hex verify 8 | reset 9 | 10 | -------------------------------------------------------------------------------- /nRF51822/timer_servo/nrf_drv_config.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | #ifndef NRF_DRV_CONFIG_H 14 | #define NRF_DRV_CONFIG_H 15 | 16 | /** 17 | * Provide a non-zero value here in applications that need to use several 18 | * peripherals with the same ID that are sharing certain resources 19 | * (for example, SPI0 and TWI0). Obviously, such peripherals cannot be used 20 | * simultaneously. Therefore, this definition allows to initialize the driver 21 | * for another peripheral from a given group only after the previously used one 22 | * is uninitialized. Normally, this is not possible, because interrupt handlers 23 | * are implemented in individual drivers. 24 | * This functionality requires a more complicated interrupt handling and driver 25 | * initialization, hence it is not always desirable to use it. 26 | */ 27 | #define PERIPHERAL_RESOURCE_SHARING_ENABLED 0 28 | 29 | /* CLOCK */ 30 | #define CLOCK_ENABLED 1 31 | #define CLOCK_CONFIG_XTAL_FREQ NRF_CLOCK_XTALFREQ_Default 32 | #define CLOCK_CONFIG_LF_SRC NRF_CLOCK_LFCLK_Xtal 33 | #define CLOCK_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 34 | 35 | /* TIMER */ 36 | #define TIMER0_ENABLED 0 37 | 38 | #if (TIMER0_ENABLED == 1) 39 | #define TIMER0_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz 40 | #define TIMER0_CONFIG_MODE TIMER_MODE_MODE_Timer 41 | #define TIMER0_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_32Bit 42 | #define TIMER0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 43 | 44 | #define TIMER0_INSTANCE_INDEX 0 45 | #endif 46 | 47 | #define TIMER1_ENABLED 1 48 | 49 | #if (TIMER1_ENABLED == 1) 50 | #define TIMER1_CONFIG_FREQUENCY NRF_TIMER_FREQ_250kHz 51 | #define TIMER1_CONFIG_MODE TIMER_MODE_MODE_Timer 52 | #define TIMER1_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit 53 | #define TIMER1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 54 | 55 | #define TIMER1_INSTANCE_INDEX (TIMER0_ENABLED) 56 | #endif 57 | 58 | #define TIMER2_ENABLED 0 59 | 60 | #if (TIMER2_ENABLED == 1) 61 | #define TIMER2_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz 62 | #define TIMER2_CONFIG_MODE TIMER_MODE_MODE_Timer 63 | #define TIMER2_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit 64 | #define TIMER2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 65 | 66 | #define TIMER2_INSTANCE_INDEX (TIMER1_ENABLED+TIMER0_ENABLED) 67 | #endif 68 | 69 | #define TIMER3_ENABLED 0 70 | 71 | #if (TIMER3_ENABLED == 1) 72 | #define TIMER3_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz 73 | #define TIMER3_CONFIG_MODE TIMER_MODE_MODE_Timer 74 | #define TIMER3_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit 75 | #define TIMER3_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 76 | 77 | #define TIMER3_INSTANCE_INDEX (TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED) 78 | #endif 79 | 80 | #define TIMER4_ENABLED 0 81 | 82 | #if (TIMER4_ENABLED == 1) 83 | #define TIMER4_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz 84 | #define TIMER4_CONFIG_MODE TIMER_MODE_MODE_Timer 85 | #define TIMER4_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit 86 | #define TIMER4_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW 87 | 88 | #define TIMER4_INSTANCE_INDEX (TIMER3_ENABLED+TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED) 89 | #endif 90 | 91 | #define TIMER_COUNT (TIMER0_ENABLED + TIMER1_ENABLED + TIMER2_ENABLED + TIMER3_ENABLED + TIMER4_ENABLED) 92 | #include "nrf_drv_config_validation.h" 93 | 94 | #endif // NRF_DRV_CONFIG_H 95 | -------------------------------------------------------------------------------- /nRF51822/timer_servo/timer_servo.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file timer_blinky.c (changed by pcbreflux) 14 | * @brief Blinky Example Application main file. 15 | * 16 | */ 17 | #include 18 | #include "nrf_delay.h" 19 | #include "nrf_gpio.h" 20 | #include "nrf_drv_clock.h" 21 | #include "nrf_drv_timer.h" 22 | #include "app_error.h" 23 | 24 | // see nrf_drv_config.h for defining TIMER1 25 | // Softdevice S110, S120, S130 blocks TIMER0 26 | const nrf_drv_timer_t mytimer1 = NRF_DRV_TIMER_INSTANCE(1); /**< Declaring an instance of nrf_drv_timer for TIMER1. */ 27 | 28 | const uint32_t led_pin1 = 19; 29 | static uint32_t tick_pos = 0; 30 | static uint32_t servo_prepos = 0; 31 | static uint32_t servo_pos = 0; 32 | const uint32_t servo_vals = 8; 33 | static uint32_t servo_val[] = { 5,10,15,20,25,20,15,10 }; 34 | 35 | /** @brief Function initialization and configuration of GPIO. 36 | */ 37 | static void gpio_config(void) { 38 | // Configure LED-pin as outputs and clear. 39 | nrf_gpio_cfg_output(led_pin1); 40 | nrf_gpio_pin_clear(led_pin1); 41 | } 42 | 43 | /** @brief Function for timer events. 44 | */ 45 | static void timer1_handler(nrf_timer_event_t event_type, void* p_context) { 46 | // uint32_t err_code; 47 | 48 | if (event_type == NRF_TIMER_EVENT_COMPARE0) { // Interrupt from COMPARE0 event. 49 | tick_pos++; 50 | if (tick_pos==1) { 51 | nrf_gpio_pin_set(led_pin1); 52 | } else if (tick_pos==servo_val[servo_pos]+1) { 53 | nrf_gpio_pin_clear(led_pin1); 54 | } else if (tick_pos==201) { 55 | servo_prepos++; 56 | if (servo_prepos==100) { 57 | if (servo_pos. * 14 | */ 15 | 16 | /** @file tt229_gpiote.c (changed by pcbreflux) 17 | * @brief Blinky Example Application main file. 18 | * 19 | */ 20 | #include 21 | #include "app_uart.h" 22 | #include "app_error.h" 23 | #include "nrf_delay.h" 24 | #include "nrf_gpiote.h" 25 | #include "nrf_gpio.h" 26 | #include "boards.h" 27 | #include "nrf_drv_gpiote.h" 28 | #include "uart.h" 29 | 30 | const uint32_t led_pin1 = 19; 31 | const uint32_t ttp229_sdo_pin = 24; 32 | const uint32_t ttp229_scl_pin = 25; 33 | static uint32_t keypress=0; 34 | 35 | uint32_t ttp229_getbit() { 36 | uint32_t retVal; 37 | 38 | nrf_gpio_pin_clear(ttp229_scl_pin); // CMOS output active-low when TP1=1 39 | nrf_delay_us(1); // 1us -> 1000kHz -> F_SCL max 512KHz first half 40 | retVal=nrf_gpio_pin_read(ttp229_sdo_pin); 41 | nrf_gpio_pin_set(ttp229_scl_pin); 42 | nrf_delay_us(1); // 1us -> 1000kHz -> F_SCL max 512KHz second half 43 | 44 | return retVal; 45 | } 46 | 47 | uint8_t ttp229_getKey8() { 48 | uint8_t retVal=0; 49 | uint8_t i; 50 | 51 | nrf_delay_us(10); // Tw 10us 52 | 53 | for (i=0; i<8; i++) { 54 | if (!ttp229_getbit()) { 55 | retVal |= (1 << i); 56 | } 57 | } 58 | nrf_delay_ms(2); // Tout 2ms 59 | 60 | return retVal; 61 | } 62 | 63 | uint16_t ttp229_getKey16() { 64 | uint16_t retVal=0; 65 | uint8_t i; 66 | 67 | nrf_delay_us(10); // Tw 10us 68 | 69 | for (i=0; i<16; i++) { 70 | if (!ttp229_getbit()) { 71 | retVal |= (1 << i); 72 | } 73 | } 74 | nrf_delay_ms(2); // Tout 2ms 75 | 76 | return retVal; 77 | } 78 | 79 | 80 | /** @brief Function initialization and configuration of RTC driver instance. 81 | */ 82 | static void gpio_config(void) { 83 | // Configure LED-pin as outputs and clear. 84 | nrf_gpio_cfg_output(led_pin1); 85 | nrf_gpio_pin_clear(led_pin1); 86 | } 87 | 88 | static void gpiote_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { 89 | // uint32_t err_code; 90 | uint16_t keys; 91 | 92 | if (pin == ttp229_sdo_pin) { 93 | if (action == NRF_GPIOTE_POLARITY_LOTOHI) { // yes it's me 94 | nrf_drv_gpiote_in_event_disable(ttp229_sdo_pin); // do not disturbe 95 | 96 | nrf_gpio_pin_toggle(led_pin1); 97 | 98 | keypress++; 99 | keys = ttp229_getKey16(); 100 | uart_printf("keypress k=%u p=%u a=%u tt229=%u\n\r",keypress,pin,action,keys); 101 | nrf_drv_gpiote_in_event_enable(ttp229_sdo_pin,true); // Event and corresponding interrupt are enabled. 102 | 103 | } 104 | } 105 | } 106 | 107 | static void gpiote_config(void) { 108 | uint32_t err_code; 109 | 110 | err_code = nrf_drv_gpiote_init(); 111 | APP_ERROR_CHECK(err_code); 112 | 113 | nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false); 114 | 115 | err_code = nrf_drv_gpiote_out_init(ttp229_scl_pin, &out_config); 116 | nrf_gpio_pin_set(ttp229_scl_pin); // active low 117 | APP_ERROR_CHECK(err_code); 118 | 119 | //nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true); // hi_accuracy off -> low power 120 | nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true); // hi_accuracy off -> low power 121 | in_config.pull = NRF_GPIO_PIN_PULLUP; 122 | err_code = nrf_drv_gpiote_in_init(ttp229_sdo_pin,&in_config,gpiote_handler); 123 | uart_printf("nrf_drv_gpiote_in_init %u\n\r",keypress); 124 | 125 | APP_ERROR_CHECK(err_code); 126 | 127 | // ppi_event_addr = nrf_drv_gpiote_in_event_addr_get(ttp229_sdo_pin); // Configure PPI using ppi_event_address. 128 | nrf_drv_gpiote_in_event_enable(ttp229_sdo_pin,true); // Event and corresponding interrupt are enabled. 129 | uart_printf("nrf_drv_gpiote_in_event_enable %u\n\r",keypress); 130 | } 131 | 132 | /** 133 | * @brief Function for application main entry. 134 | */ 135 | int main(void) { 136 | // uint32_t retVal; 137 | uint32_t pos=0; 138 | 139 | uart_init(); 140 | uart_printf("\n\rstart tt229 gpiote\n\r"); 141 | 142 | // setup 143 | gpio_config(); // Configure GPIO pins. 144 | gpiote_config(); // Configure GPIOTE Events. 145 | 146 | // loop 147 | while (true) { 148 | // retVal=nrf_gpio_pin_read(ttp229_sdo_pin); 149 | nrf_delay_ms(10000); 150 | uart_printf("tick (%u)\n\r",pos++); 151 | 152 | /* 153 | // Enter System ON sleep mode 154 | __WFE(); 155 | // Make sure any pending events are cleared 156 | __SEV(); 157 | __WFE(); 158 | */ 159 | } 160 | } 161 | 162 | 163 | /** @} */ 164 | -------------------------------------------------------------------------------- /nRF51822/ttp229_gpiote/uart.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | 17 | /** 18 | * @brief UART header file. 19 | * 20 | * This file contains the source code for a application using UART. 21 | * 22 | */ 23 | #include 24 | #include "app_uart.h" 25 | #include "app_error.h" 26 | #include "nrf.h" 27 | //#include "nrf_drv_config.h" 28 | #include "bsp.h" 29 | #include "uart.h" 30 | 31 | #define MAX_TEST_DATA_BYTES (15U) /**< max number of test bytes to be used for tx and rx. */ 32 | #define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */ 33 | #define UART_RX_BUF_SIZE 1 /**< UART RX buffer size. */ 34 | 35 | /** 36 | * @brief Function for uart_error_handle uart error handling. 37 | */ 38 | void uart_error_handle(app_uart_evt_t * p_event) { 39 | if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR) { 40 | APP_ERROR_HANDLER(p_event->data.error_communication); 41 | } else if (p_event->evt_type == APP_UART_FIFO_ERROR) { 42 | APP_ERROR_HANDLER(p_event->data.error_code); 43 | } 44 | } 45 | 46 | 47 | /** 48 | * @brief Function for uart_write write string to uart function. 49 | * @param out output string 50 | */ 51 | void uart_write(const char* out) { 52 | while(*out) { 53 | while(app_uart_put(*out++) != NRF_SUCCESS); 54 | } 55 | } 56 | 57 | /** 58 | * @brief Function for uart_printf print formated to uart function. 59 | * @param format_out output format 60 | * @param ... output variables 61 | */ 62 | void uart_printf(const char * format_out, ...) { 63 | static char outbuffer[256]; 64 | 65 | va_list p_args; 66 | va_start(p_args, format_out); 67 | vsprintf(outbuffer, format_out, p_args); 68 | va_end(p_args); 69 | uart_write(outbuffer); 70 | } 71 | 72 | /** 73 | * @brief Function for uart_init initialise my uart function. 74 | */ 75 | void uart_init(void) { 76 | uint32_t err_code; 77 | 78 | const app_uart_comm_params_t comm_params = { 79 | RX_PIN_NUMBER, 80 | TX_PIN_NUMBER, 81 | RTS_PIN_NUMBER, 82 | CTS_PIN_NUMBER, 83 | HWFC?APP_UART_FLOW_CONTROL_ENABLED:APP_UART_FLOW_CONTROL_DISABLED, 84 | false, // use_parity 85 | UART0_CONFIG_BAUDRATE 86 | }; 87 | 88 | APP_UART_FIFO_INIT(&comm_params, 89 | UART_RX_BUF_SIZE, 90 | UART_TX_BUF_SIZE, 91 | uart_error_handle, 92 | APP_IRQ_PRIORITY_LOW, 93 | err_code); 94 | 95 | APP_ERROR_CHECK(err_code); 96 | } 97 | 98 | -------------------------------------------------------------------------------- /nRF51822/ttp229_gpiote/uart.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | 17 | #ifndef UART_H 18 | #define UART_H 19 | /** 20 | * @brief UART header file. 21 | * 22 | * This file contains the defining code for a application using UART. 23 | * 24 | */ 25 | 26 | /** 27 | * @brief Function for uart_error_handle uart error handling. 28 | */ 29 | void uart_error_handle(app_uart_evt_t * p_event); 30 | 31 | /** 32 | * @brief Function for uart_write write string to uart function. 33 | * @param out output string 34 | */ 35 | void uart_write(const char* out); 36 | 37 | /** 38 | * @brief Function for uart_printf print formated to uart function. 39 | * @param format_out output format 40 | * @param ... output variables 41 | */ 42 | void uart_printf(const char * format_out, ...); 43 | 44 | /** 45 | * @brief Function for uart_init initialise my uart function. 46 | */ 47 | void uart_init(void); 48 | 49 | #endif // UART_H 50 | -------------------------------------------------------------------------------- /nRF51822/uart/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF_LOG_USES_UART=1 8 | ASFLAGS += -g 9 | ASMFLAGS += -DBOARD_CUSTOM 10 | ASMFLAGS += -DNRF_LOG_USES_UART=1 11 | 12 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf51822_QFAA.ld 13 | 14 | # object files 15 | 16 | OBJS = system_nrf51.o app_error.o app_fifo.o app_util_platform.o nrf_assert.o app_uart_fifo.o nrf_drv_common.o nrf_delay.o nrf_drv_uart.o 17 | OBJS += nrf_log.o uart.o main.o 18 | 19 | # include common make file 20 | 21 | include $(TEMPLATEROOT)/Makefile.common 22 | -------------------------------------------------------------------------------- /nRF51822/uart/flash.txt: -------------------------------------------------------------------------------- 1 | openocd -d3 -f ../openocd.cfg 2 | telnet 127.0.0.1 4444 3 | reset halt 4 | nrf51 mass_erase 5 | ##flash banks 6 | reset halt 7 | program /home/pcbreflux/nordic/nordic.git/nRF51822/uart/_build/uart.hex verify 8 | reset 9 | 10 | -------------------------------------------------------------------------------- /nRF51822/uart/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file 14 | * @defgroup uart_example_main main.c (changed by pcbreflux) 15 | * @{ 16 | * @ingroup uart_example 17 | * @brief UART Example Application main file. 18 | * 19 | * This file contains the source code for a sample application using UART. 20 | * 21 | */ 22 | #include 23 | #include "app_uart.h" 24 | #include "app_error.h" 25 | #include "nrf_delay.h" 26 | #include "nrf_gpio.h" 27 | #include "uart.h" 28 | 29 | const uint32_t led_pin1 = 19; 30 | 31 | /** @brief Function initialization and configuration of RTC driver instance. 32 | */ 33 | static void gpio_config(void) { 34 | // Configure LED-pin as outputs and clear. 35 | nrf_gpio_cfg_output(led_pin1); 36 | nrf_gpio_pin_clear(led_pin1); 37 | } 38 | 39 | /** 40 | * @brief Function for main application entry. 41 | */ 42 | int main(void) { 43 | 44 | gpio_config(); 45 | uart_init(); 46 | 47 | uart_printf("\n\rStart: \n\r"); 48 | 49 | uint32_t pos=0xFFFFFF00; // -> next to 0 50 | while (true) { 51 | nrf_gpio_pin_toggle(led_pin1); 52 | uart_printf("Counter: %u\n\r",pos); 53 | nrf_delay_ms(500); 54 | pos++; 55 | } 56 | } 57 | 58 | 59 | /** @} */ 60 | -------------------------------------------------------------------------------- /nRF51822/uart/readme.txt: -------------------------------------------------------------------------------- 1 | sudo usermod -a -G dialout $USER 2 | sudo apt-get install putty 3 | -------------------------------------------------------------------------------- /nRF51822/uart/uart.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | 17 | /** 18 | * @brief UART header file. 19 | * 20 | * This file contains the source code for a application using UART. 21 | * 22 | */ 23 | #include 24 | #include "app_uart.h" 25 | #include "app_error.h" 26 | #include "nrf.h" 27 | //#include "nrf_drv_config.h" 28 | #include "bsp.h" 29 | #include "uart.h" 30 | 31 | #define MAX_TEST_DATA_BYTES (15U) /**< max number of test bytes to be used for tx and rx. */ 32 | #define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */ 33 | #define UART_RX_BUF_SIZE 1 /**< UART RX buffer size. */ 34 | 35 | /** 36 | * @brief Function for uart_error_handle uart error handling. 37 | */ 38 | void uart_error_handle(app_uart_evt_t * p_event) { 39 | if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR) { 40 | APP_ERROR_HANDLER(p_event->data.error_communication); 41 | } else if (p_event->evt_type == APP_UART_FIFO_ERROR) { 42 | APP_ERROR_HANDLER(p_event->data.error_code); 43 | } 44 | } 45 | 46 | 47 | /** 48 | * @brief Function for uart_write write string to uart function. 49 | * @param out output string 50 | */ 51 | void uart_write(const char* out) { 52 | while(*out) { 53 | while(app_uart_put(*out++) != NRF_SUCCESS); 54 | } 55 | } 56 | 57 | /** 58 | * @brief Function for uart_printf print formated to uart function. 59 | * @param format_out output format 60 | * @param ... output variables 61 | */ 62 | void uart_printf(const char * format_out, ...) { 63 | static char outbuffer[256]; 64 | 65 | va_list p_args; 66 | va_start(p_args, format_out); 67 | vsprintf(outbuffer, format_out, p_args); 68 | va_end(p_args); 69 | uart_write(outbuffer); 70 | } 71 | 72 | /** 73 | * @brief Function for uart_init initialise my uart function. 74 | */ 75 | void uart_init(void) { 76 | uint32_t err_code; 77 | 78 | const app_uart_comm_params_t comm_params = { 79 | RX_PIN_NUMBER, 80 | TX_PIN_NUMBER, 81 | RTS_PIN_NUMBER, 82 | CTS_PIN_NUMBER, 83 | HWFC?APP_UART_FLOW_CONTROL_ENABLED:APP_UART_FLOW_CONTROL_DISABLED, 84 | false, // use_parity 85 | UART0_CONFIG_BAUDRATE 86 | }; 87 | 88 | APP_UART_FIFO_INIT(&comm_params, 89 | UART_RX_BUF_SIZE, 90 | UART_TX_BUF_SIZE, 91 | uart_error_handle, 92 | APP_IRQ_PRIORITY_LOW, 93 | err_code); 94 | 95 | APP_ERROR_CHECK(err_code); 96 | } 97 | 98 | -------------------------------------------------------------------------------- /nRF51822/uart/uart.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 pcbreflux. All Rights Reserved. 2 | * 3 | * This program is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, version 3. 6 | * 7 | * This program is distributed in the hope that it will be useful, but 8 | * WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | * General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program. If not, see . * 14 | */ 15 | 16 | 17 | #ifndef UART_H 18 | #define UART_H 19 | /** 20 | * @brief UART header file. 21 | * 22 | * This file contains the defining code for a application using UART. 23 | * 24 | */ 25 | 26 | /** 27 | * @brief Function for uart_error_handle uart error handling. 28 | */ 29 | void uart_error_handle(app_uart_evt_t * p_event); 30 | 31 | /** 32 | * @brief Function for uart_write write string to uart function. 33 | * @param out output string 34 | */ 35 | void uart_write(const char* out); 36 | 37 | /** 38 | * @brief Function for uart_printf print formated to uart function. 39 | * @param format_out output format 40 | * @param ... output variables 41 | */ 42 | void uart_printf(const char * format_out, ...); 43 | 44 | /** 45 | * @brief Function for uart_init initialise my uart function. 46 | */ 47 | void uart_init(void); 48 | 49 | #endif // UART_H 50 | -------------------------------------------------------------------------------- /nRF52832/Testboard.txt: -------------------------------------------------------------------------------- 1 | D30 = P0.24 2 | D29 = P0.23 3 | D28 = P0.22 4 | D27 = P0.20 5 | D26 = P0.19 6 | D25 = P0.18 7 | D24 = P0.17 8 | D23 = P0.16 9 | D22 = P0.15 10 | D21 = P0.14 11 | D20 = P0.13 12 | D19 = P0.12 13 | D18 = P0.11 14 | D17 = P0.10 15 | D16 = P0.09 16 | TCK = SWCLK 17 | TMS = SWDIO 18 | D15 = P0.08 19 | D14 = P0.07 20 | D13 = P0.06 21 | D12 = P0.01 22 | D11 = P0.00 23 | D10 = P0.05 24 | D09 = P0.04 25 | D08 = P0.03 26 | D07 = P0.02 27 | D06 = P0.31 LED 1 28 | D05 = P0.30 LED 2 29 | D04 = P0.29 30 | D03 = P0.28 31 | D02 = P0.27 32 | D01 = P0.26 33 | D00 = P0.25 34 | -------------------------------------------------------------------------------- /nRF52832/blank_nrf52832_QFAA.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 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 | } INSERT AFTER .data; 21 | 22 | INCLUDE "nrf5x_common.ld" 23 | -------------------------------------------------------------------------------- /nRF52832/blinky/.gitignore: -------------------------------------------------------------------------------- 1 | .cproject 2 | .project 3 | .settings 4 | -------------------------------------------------------------------------------- /nRF52832/blinky/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF52832 8 | ASFLAGS += -g 9 | ASMFLAGS += -DBOARD_CUSTOM 10 | ASMFLAGS += -DNRF52832 11 | 12 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf52832_QFAA.ld 13 | 14 | # object files 15 | 16 | OBJS = system_nrf52.o main.o 17 | 18 | # include common make file 19 | 20 | include $(TEMPLATEROOT)/Makefile.common 21 | -------------------------------------------------------------------------------- /nRF52832/blinky/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file blinky.c (changed by pcbreflux) 14 | * @brief Blinky Example Application main file. 15 | * 16 | */ 17 | #include 18 | #include "nrf_delay.h" 19 | #include "nrf_gpio.h" 20 | 21 | const uint32_t led_pin1 = 31; 22 | const uint32_t led_pin2 = 30; 23 | 24 | /** 25 | * @brief Function for application main entry. 26 | */ 27 | int main(void) { 28 | 29 | // setup 30 | // Configure LED-pin as outputs and clear. 31 | nrf_gpio_cfg_output(led_pin1); 32 | nrf_gpio_pin_clear(led_pin1); 33 | nrf_gpio_cfg_output(led_pin2); 34 | nrf_gpio_pin_set(led_pin2); 35 | 36 | // loop 37 | // Toggle LED. 38 | while (true) { 39 | nrf_gpio_pin_toggle(led_pin1); 40 | nrf_gpio_pin_toggle(led_pin2); 41 | nrf_delay_ms(1000); 42 | } 43 | } 44 | 45 | 46 | /** @} */ 47 | -------------------------------------------------------------------------------- /nRF52832/board1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pcbreflux/nordic/7094312fe7913cde2ad25ce3926fe5dfad35948a/nRF52832/board1.jpg -------------------------------------------------------------------------------- /nRF52832/openocd_nrf52.cfg: -------------------------------------------------------------------------------- 1 | #nRF52832 Target 2 | source [find interface/stlink-v2.cfg] 3 | 4 | transport select hla_swd 5 | 6 | source [find target/nrf52.cfg] 7 | 8 | 9 | -------------------------------------------------------------------------------- /nRF52840/blank_nrf52840_QFIA.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x100000 9 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000 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 | } INSERT AFTER .data; 21 | 22 | SECTIONS 23 | { 24 | .pwr_mgmt_data : 25 | { 26 | PROVIDE(__start_pwr_mgmt_data = .); 27 | KEEP(*(.pwr_mgmt_data)) 28 | PROVIDE(__stop_pwr_mgmt_data = .); 29 | } > FLASH 30 | } INSERT AFTER .text 31 | 32 | INCLUDE "nrf5x_common.ld" 33 | -------------------------------------------------------------------------------- /nRF52840/ble_app_beacon_13/Makefile: -------------------------------------------------------------------------------- 1 | Makefile.S140 -------------------------------------------------------------------------------- /nRF52840/ble_app_beacon_13/Makefile.S140: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_CUSTOM 7 | CFLAGS += -DNRF52840_XXAA 8 | CFLAGS += -DNRF_LOG_USES_UART=1 9 | CFLAGS += -DSOFTDEVICE_PRESENT 10 | CFLAGS += -DS140 11 | CFLAGS += -DNRF_SD_BLE_API_VERSION=5 12 | CFLAGS += -DBLE_STACK_SUPPORT_REQD 13 | CFLAGS += -DSWI_DISABLE0 14 | ASMFLAGS += -g 15 | ASMFLAGS += -DBOARD_CUSTOM 16 | ASMFLAGS += -DNRF52840_XXAA 17 | ASMFLAGS += -DNRF_LOG_USES_UART=1 18 | ASMFLAGS += -DSOFTDEVICE_PRESENT 19 | ASMFLAGS += -DS140 20 | ASMFLAGS += -DNRF_SD_BLE_API_VERSION=5 21 | ASMFLAGS += -DBLE_STACK_SUPPORT_REQD 22 | ASMFLAGS += -DSWI_DISABLE0 23 | 24 | LDSCRIPT = ./s140_v2_nrf52840_QIAA.ld 25 | INC_PATHS += -I$(SDK_PATH)/components/softdevice/s140/headers 26 | 27 | vpath %.c $(SDK_PATH)/components/softdevice/s140/headers 28 | 29 | # object files 30 | 31 | OBJS = nrf_log_backend_serial.o nrf_log_frontend.o 32 | OBJS += app_button.o app_error.o app_error_weak.o app_fifo.o app_timer.o app_util_platform.o 33 | OBJS += hardfault_implementation.o nrf_assert.o 34 | OBJS += nrf_drv_clock.o nrf_drv_common.o nrf_drv_gpiote.o nrf_drv_uart.o 35 | OBJS += boards.o bsp.o main.o 36 | OBJS += ble_advdata.o ble_conn_params.o ble_srv_common.o 37 | OBJS += system_nrf52840.o softdevice_handler.o 38 | # include common make file 39 | 40 | include $(TEMPLATEROOT)/Makefile.common 41 | -------------------------------------------------------------------------------- /nRF52840/ble_app_beacon_13/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pcbreflux/nordic/7094312fe7913cde2ad25ce3926fe5dfad35948a/nRF52840/ble_app_beacon_13/license.txt -------------------------------------------------------------------------------- /nRF52840/ble_app_beacon_13/s140_v2_nrf52840_QIAA.ld: -------------------------------------------------------------------------------- 1 | /* Linker script to configure memory regions. */ 2 | 3 | SEARCH_DIR(.) 4 | GROUP(-lgcc -lc -lnosys) 5 | 6 | MEMORY 7 | { 8 | FLASH (rx) : ORIGIN = 0x21000, LENGTH = 0xdf000 9 | RAM (rwx) : ORIGIN = 0x20001930, LENGTH = 0x3e6d0 10 | } 11 | 12 | SECTIONS 13 | { 14 | . = ALIGN(4); 15 | .fs_data : 16 | { 17 | PROVIDE(__start_fs_data = .); 18 | KEEP(*(.fs_data)) 19 | PROVIDE(__stop_fs_data = .); 20 | } > RAM 21 | } INSERT AFTER .data; 22 | 23 | INCLUDE "nrf5x_common.ld" 24 | -------------------------------------------------------------------------------- /nRF52840/blinky_13/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | blinky_13 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | 26 | 27 | -------------------------------------------------------------------------------- /nRF52840/blinky_13/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /nRF52840/blinky_13/Makefile: -------------------------------------------------------------------------------- 1 | TEMPLATEROOT = .. 2 | 3 | # compilation flags for gdb 4 | 5 | CFLAGS += -O0 -g 6 | CFLAGS += -DBOARD_PCA10056 7 | CFLAGS += -DSWI_DISABLE0 8 | CFLAGS += -DNRF52840_XXAA 9 | CFLAGS += -DBOARD_PCA10056 10 | CFLAGS += -DCONFIG_GPIO_AS_PINRESET 11 | ASFLAGS += -g 12 | ASMFLAGS += -DSWI_DISABLE0 13 | ASMFLAGS += -DNRF52840_XXAA 14 | ASMFLAGS += -DBOARD_PCA10056 15 | ASMFLAGS += -DBSP_DEFINES_ONLY 16 | ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET 17 | 18 | LDSCRIPT = $(TEMPLATEROOT)/blank_nrf52840_QFIA.ld 19 | 20 | # object files 21 | 22 | OBJS = system_nrf52840.o main.o 23 | 24 | # include common make file 25 | 26 | include $(TEMPLATEROOT)/Makefile.common -------------------------------------------------------------------------------- /nRF52840/blinky_13/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /** @file blinky.c (changed by pcbreflux) 14 | * @brief Blinky Example Application main file. 15 | * 16 | */ 17 | #include 18 | #include 19 | #include 20 | #include "nrf_delay.h" 21 | #include "nrf_gpio.h" 22 | 23 | const uint32_t led_pin[] = { 13,14,15,16 }; 24 | #define LEDPINS 4 25 | /** 26 | * @brief Function for application main entry. 27 | */ 28 | int main(void) { 29 | 30 | uint8_t pos=0; 31 | // setup 32 | // Configure LED-pin as outputs and clear. 33 | for (pos=0;pos=LEDPINS) { 46 | pos=0; 47 | } 48 | } 49 | } 50 | 51 | 52 | /** @} */ 53 | -------------------------------------------------------------------------------- /nRF52840/custom_board.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Nordic Semiconductor. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Nordic Semiconductor ASA. 4 | * Terms and conditions of usage are described in detail in NORDIC 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | #ifndef PCA10056_H 13 | #define PCA10056_H 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #include "nrf_gpio.h" 20 | 21 | // LEDs definitions for PCA10056 22 | #define LEDS_NUMBER 4 23 | 24 | #define LED_1 NRF_GPIO_PIN_MAP(0,13) 25 | #define LED_2 NRF_GPIO_PIN_MAP(0,14) 26 | #define LED_3 NRF_GPIO_PIN_MAP(0,15) 27 | #define LED_4 NRF_GPIO_PIN_MAP(0,16) 28 | 29 | #define LEDS_ACTIVE_STATE 0 30 | 31 | #define LEDS_LIST { LED_1, LED_2, LED_3, LED_4 } 32 | 33 | #define LEDS_INV_MASK LEDS_MASK 34 | 35 | #define BSP_LED_0 13 36 | #define BSP_LED_1 14 37 | #define BSP_LED_2 15 38 | #define BSP_LED_3 16 39 | 40 | #define BUTTONS_NUMBER 4 41 | 42 | #define BUTTON_1 11 43 | #define BUTTON_2 12 44 | #define BUTTON_3 24 45 | #define BUTTON_4 25 46 | #define BUTTON_PULL NRF_GPIO_PIN_PULLUP 47 | 48 | #define BUTTONS_ACTIVE_STATE 0 49 | 50 | #define BUTTONS_LIST { BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4 } 51 | 52 | #define BSP_BUTTON_0 BUTTON_1 53 | #define BSP_BUTTON_1 BUTTON_2 54 | #define BSP_BUTTON_2 BUTTON_3 55 | #define BSP_BUTTON_3 BUTTON_4 56 | 57 | #define RX_PIN_NUMBER 8 58 | #define TX_PIN_NUMBER 6 59 | #define CTS_PIN_NUMBER 7 60 | #define RTS_PIN_NUMBER 5 61 | #define HWFC false 62 | 63 | #define BSP_QSPI_SCK_PIN 19 64 | #define BSP_QSPI_CSN_PIN 17 65 | #define BSP_QSPI_IO0_PIN 20 66 | #define BSP_QSPI_IO1_PIN 21 67 | #define BSP_QSPI_IO2_PIN 22 68 | #define BSP_QSPI_IO3_PIN 23 69 | 70 | 71 | // serialization APPLICATION board - temp. setup for running serialized MEMU tests 72 | #define SER_APP_RX_PIN NRF_GPIO_PIN_MAP(1,13) // UART RX pin number. 73 | #define SER_APP_TX_PIN NRF_GPIO_PIN_MAP(1,14) // UART TX pin number. 74 | #define SER_APP_CTS_PIN NRF_GPIO_PIN_MAP(0,2) // UART Clear To Send pin number. 75 | #define SER_APP_RTS_PIN NRF_GPIO_PIN_MAP(1,15) // UART Request To Send pin number. 76 | 77 | #define SER_APP_SPIM0_SCK_PIN NRF_GPIO_PIN_MAP(0,27) // SPI clock GPIO pin number. 78 | #define SER_APP_SPIM0_MOSI_PIN NRF_GPIO_PIN_MAP(0,2) // SPI Master Out Slave In GPIO pin number 79 | #define SER_APP_SPIM0_MISO_PIN NRF_GPIO_PIN_MAP(0,26) // SPI Master In Slave Out GPIO pin number 80 | #define SER_APP_SPIM0_SS_PIN NRF_GPIO_PIN_MAP(1,13) // SPI Slave Select GPIO pin number 81 | #define SER_APP_SPIM0_RDY_PIN NRF_GPIO_PIN_MAP(1,15) // SPI READY GPIO pin number 82 | #define SER_APP_SPIM0_REQ_PIN NRF_GPIO_PIN_MAP(1,14) // SPI REQUEST GPIO pin number 83 | 84 | // serialization CONNECTIVITY board 85 | #define SER_CON_RX_PIN NRF_GPIO_PIN_MAP(1,14) // UART RX pin number. 86 | #define SER_CON_TX_PIN NRF_GPIO_PIN_MAP(1,13) // UART TX pin number. 87 | #define SER_CON_CTS_PIN NRF_GPIO_PIN_MAP(1,15) // UART Clear To Send pin number. Not used if HWFC is set to false. 88 | #define SER_CON_RTS_PIN NRF_GPIO_PIN_MAP(0,2) // UART Request To Send pin number. Not used if HWFC is set to false. 89 | 90 | 91 | #define SER_CON_SPIS_SCK_PIN NRF_GPIO_PIN_MAP(0,27) // SPI SCK signal. 92 | #define SER_CON_SPIS_MOSI_PIN NRF_GPIO_PIN_MAP(0,2) // SPI MOSI signal. 93 | #define SER_CON_SPIS_MISO_PIN NRF_GPIO_PIN_MAP(0,26) // SPI MISO signal. 94 | #define SER_CON_SPIS_CSN_PIN NRF_GPIO_PIN_MAP(1,13) // SPI CSN signal. 95 | #define SER_CON_SPIS_RDY_PIN NRF_GPIO_PIN_MAP(1,15) // SPI READY GPIO pin number. 96 | #define SER_CON_SPIS_REQ_PIN NRF_GPIO_PIN_MAP(1,14) // SPI REQUEST GPIO pin number. 97 | 98 | #define SER_CONN_CHIP_RESET_PIN NRF_GPIO_PIN_MAP(1,1) // Pin used to reset connectivity chip 99 | 100 | // Arduino board mappings 101 | #define ARDUINO_SCL_PIN 27 // SCL signal pin 102 | #define ARDUINO_SDA_PIN 26 // SDA signal pin 103 | #define ARDUINO_AREF_PIN 2 // Aref pin 104 | 105 | #define ARDUINO_13_PIN NRF_GPIO_PIN_MAP(1, 15) // Digital pin 13 106 | #define ARDUINO_12_PIN NRF_GPIO_PIN_MAP(1, 14) // Digital pin 12 107 | #define ARDUINO_11_PIN NRF_GPIO_PIN_MAP(1, 13) // Digital pin 11 108 | #define ARDUINO_10_PIN NRF_GPIO_PIN_MAP(1, 12) // Digital pin 10 109 | #define ARDUINO_9_PIN NRF_GPIO_PIN_MAP(1, 11) // Digital pin 9 110 | #define ARDUINO_8_PIN NRF_GPIO_PIN_MAP(1, 10) // Digital pin 8 111 | 112 | #define ARDUINO_7_PIN NRF_GPIO_PIN_MAP(1, 8) // Digital pin 7 113 | #define ARDUINO_6_PIN NRF_GPIO_PIN_MAP(1, 7) // Digital pin 6 114 | #define ARDUINO_5_PIN NRF_GPIO_PIN_MAP(1, 6) // Digital pin 5 115 | #define ARDUINO_4_PIN NRF_GPIO_PIN_MAP(1, 5) // Digital pin 4 116 | #define ARDUINO_3_PIN NRF_GPIO_PIN_MAP(1, 4) // Digital pin 3 117 | #define ARDUINO_2_PIN NRF_GPIO_PIN_MAP(1, 3) // Digital pin 2 118 | #define ARDUINO_1_PIN NRF_GPIO_PIN_MAP(1, 2) // Digital pin 1 119 | #define ARDUINO_0_PIN NRF_GPIO_PIN_MAP(1, 1) // Digital pin 0 120 | 121 | #define ARDUINO_A0_PIN 3 // Analog channel 0 122 | #define ARDUINO_A1_PIN 4 // Analog channel 1 123 | #define ARDUINO_A2_PIN 28 // Analog channel 2 124 | #define ARDUINO_A3_PIN 29 // Analog channel 3 125 | #define ARDUINO_A4_PIN 30 // Analog channel 4 126 | #define ARDUINO_A5_PIN 31 // Analog channel 5 127 | 128 | // Low frequency clock source to be used by the SoftDevice 129 | #define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_XTAL, \ 130 | .rc_ctiv = 0, \ 131 | .rc_temp_ctiv = 0, \ 132 | .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM} 133 | 134 | #ifdef __cplusplus 135 | } 136 | #endif 137 | 138 | #endif // PCA10056_H 139 | --------------------------------------------------------------------------------