Philip Freidin
/
OSHChip_Blinky
Simple test of tool chain with OSHChip
OSHChip_Init.c@1:23b7ed707d25, 2016-03-26 (annotated)
- Committer:
- OSHChip
- Date:
- Sat Mar 26 07:32:50 2016 +0000
- Revision:
- 1:23b7ed707d25
- Parent:
- 0:69ded1c7cad0
Added code to OSHChip_Init.c to change Baud
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OSHChip | 0:69ded1c7cad0 | 1 | // |
OSHChip | 0:69ded1c7cad0 | 2 | // OSHChip_Init.cpp |
OSHChip | 0:69ded1c7cad0 | 3 | // |
OSHChip | 0:69ded1c7cad0 | 4 | // This function allows OSHChip projects that use the UART for printf() |
OSHChip | 0:69ded1c7cad0 | 5 | // to work with the target board set to nRF51-DK |
OSHChip | 0:69ded1c7cad0 | 6 | // |
OSHChip | 0:69ded1c7cad0 | 7 | |
OSHChip | 0:69ded1c7cad0 | 8 | // |
OSHChip | 0:69ded1c7cad0 | 9 | // By the time your program gets to main(), the pre-main initialization has |
OSHChip | 0:69ded1c7cad0 | 10 | // (among other things) setup the UART to use the nRF51-DK UART pins, and a |
OSHChip | 0:69ded1c7cad0 | 11 | // transmission speed of 9600 Baud, 8N1. |
OSHChip | 0:69ded1c7cad0 | 12 | // |
OSHChip | 0:69ded1c7cad0 | 13 | // nRF51-DK |
OSHChip | 0:69ded1c7cad0 | 14 | // RX_PIN_NUMBER = p11, |
OSHChip | 0:69ded1c7cad0 | 15 | // TX_PIN_NUMBER = p9, |
OSHChip | 0:69ded1c7cad0 | 16 | // CTS_PIN_NUMBER = p10, |
OSHChip | 0:69ded1c7cad0 | 17 | // RTS_PIN_NUMBER = p8, |
OSHChip | 0:69ded1c7cad0 | 18 | // |
OSHChip | 0:69ded1c7cad0 | 19 | // For OSHChip, the default is TX on pin 1, RX on pin 2, and no CTS or RTS |
OSHChip | 0:69ded1c7cad0 | 20 | // because OSHChip has so few I/O pins. |
OSHChip | 0:69ded1c7cad0 | 21 | // |
OSHChip | 0:69ded1c7cad0 | 22 | // Due to the default implementation of Serial I/O in mbed, when \n |
OSHChip | 0:69ded1c7cad0 | 23 | // is set to the UART, all that is actually transmitted is the "newline". |
OSHChip | 0:69ded1c7cad0 | 24 | // In a Unix/Mac environment this is usually sufficient, but in a |
OSHChip | 0:69ded1c7cad0 | 25 | // DOS/Windows environment, \n\r needs to be sent. |
OSHChip | 0:69ded1c7cad0 | 26 | // |
OSHChip | 0:69ded1c7cad0 | 27 | // If you are using the Serial to USB service on the OSHChip_CMSIS_DAP, |
OSHChip | 0:69ded1c7cad0 | 28 | // TXD (pin 1 on OSHChip as configured by this function) should be |
OSHChip | 0:69ded1c7cad0 | 29 | // connected to the pin closest to the corner of the PCB on connector J5, |
OSHChip | 0:69ded1c7cad0 | 30 | // which is labeled "RX In". RXD (pin 2 on OSHChip as configured by this |
OSHChip | 0:69ded1c7cad0 | 31 | // function) should be connected to the other pin on J5 which is labeled |
OSHChip | 0:69ded1c7cad0 | 32 | // "TX Out" |
OSHChip | 0:69ded1c7cad0 | 33 | // |
OSHChip | 0:69ded1c7cad0 | 34 | |
OSHChip | 0:69ded1c7cad0 | 35 | #include "nrf51.h" |
OSHChip | 1:23b7ed707d25 | 36 | #include "nrf51_bitfields.h" |
OSHChip | 0:69ded1c7cad0 | 37 | #include "OSHChip_Pin_Names.h" |
OSHChip | 0:69ded1c7cad0 | 38 | |
OSHChip | 0:69ded1c7cad0 | 39 | void OSHChip_Init(void) |
OSHChip | 0:69ded1c7cad0 | 40 | { |
OSHChip | 0:69ded1c7cad0 | 41 | NRF_UART0->PSELTXD = TX_PIN_NUMBER; |
OSHChip | 0:69ded1c7cad0 | 42 | NRF_UART0->PSELRXD = RX_PIN_NUMBER; |
OSHChip | 0:69ded1c7cad0 | 43 | NRF_UART0->PSELRTS = 0xFFFFFFFF; |
OSHChip | 0:69ded1c7cad0 | 44 | NRF_UART0->PSELCTS = 0xFFFFFFFF; |
OSHChip | 1:23b7ed707d25 | 45 | |
OSHChip | 1:23b7ed707d25 | 46 | // |
OSHChip | 1:23b7ed707d25 | 47 | // If you want to change the default Baud, uncomment the following assignment |
OSHChip | 1:23b7ed707d25 | 48 | // |
OSHChip | 1:23b7ed707d25 | 49 | // Here are the pre-defined Baud values: |
OSHChip | 1:23b7ed707d25 | 50 | // |
OSHChip | 1:23b7ed707d25 | 51 | // UART_BAUDRATE_BAUDRATE_Baud1200, UART_BAUDRATE_BAUDRATE_Baud2400, UART_BAUDRATE_BAUDRATE_Baud4800, |
OSHChip | 1:23b7ed707d25 | 52 | // UART_BAUDRATE_BAUDRATE_Baud9600, UART_BAUDRATE_BAUDRATE_Baud14400, UART_BAUDRATE_BAUDRATE_Baud19200, |
OSHChip | 1:23b7ed707d25 | 53 | // UART_BAUDRATE_BAUDRATE_Baud28800, UART_BAUDRATE_BAUDRATE_Baud38400, UART_BAUDRATE_BAUDRATE_Baud57600, |
OSHChip | 1:23b7ed707d25 | 54 | // UART_BAUDRATE_BAUDRATE_Baud76800, UART_BAUDRATE_BAUDRATE_Baud115200, UART_BAUDRATE_BAUDRATE_Baud230400, |
OSHChip | 1:23b7ed707d25 | 55 | // UART_BAUDRATE_BAUDRATE_Baud250000, UART_BAUDRATE_BAUDRATE_Baud460800, UART_BAUDRATE_BAUDRATE_Baud921600, |
OSHChip | 1:23b7ed707d25 | 56 | // UART_BAUDRATE_BAUDRATE_Baud1M |
OSHChip | 1:23b7ed707d25 | 57 | |
OSHChip | 1:23b7ed707d25 | 58 | // NRF_UART0->BAUDRATE = UART_BAUDRATE_BAUDRATE_Baud115200; |
OSHChip | 1:23b7ed707d25 | 59 | |
OSHChip | 0:69ded1c7cad0 | 60 | } |