Philip Freidin
/
OSHChip_Blinky
Simple test of tool chain with OSHChip
Diff: OSHChip_Init.c
- Revision:
- 0:69ded1c7cad0
- Child:
- 1:23b7ed707d25
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OSHChip_Init.c Tue Mar 22 07:57:23 2016 +0000 @@ -0,0 +1,44 @@ +// +// OSHChip_Init.cpp +// +// This function allows OSHChip projects that use the UART for printf() +// to work with the target board set to nRF51-DK +// + +// +// By the time your program gets to main(), the pre-main initialization has +// (among other things) setup the UART to use the nRF51-DK UART pins, and a +// transmission speed of 9600 Baud, 8N1. +// +// nRF51-DK +// RX_PIN_NUMBER = p11, +// TX_PIN_NUMBER = p9, +// CTS_PIN_NUMBER = p10, +// RTS_PIN_NUMBER = p8, +// +// For OSHChip, the default is TX on pin 1, RX on pin 2, and no CTS or RTS +// because OSHChip has so few I/O pins. +// +// Due to the default implementation of Serial I/O in mbed, when \n +// is set to the UART, all that is actually transmitted is the "newline". +// In a Unix/Mac environment this is usually sufficient, but in a +// DOS/Windows environment, \n\r needs to be sent. +// +// If you are using the Serial to USB service on the OSHChip_CMSIS_DAP, +// TXD (pin 1 on OSHChip as configured by this function) should be +// connected to the pin closest to the corner of the PCB on connector J5, +// which is labeled "RX In". RXD (pin 2 on OSHChip as configured by this +// function) should be connected to the other pin on J5 which is labeled +// "TX Out" +// + +#include "nrf51.h" +#include "OSHChip_Pin_Names.h" + +void OSHChip_Init(void) +{ + NRF_UART0->PSELTXD = TX_PIN_NUMBER; + NRF_UART0->PSELRXD = RX_PIN_NUMBER; + NRF_UART0->PSELRTS = 0xFFFFFFFF; + NRF_UART0->PSELCTS = 0xFFFFFFFF; +}