summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/main.c b/main.c
index c5ee04b..fea90ad 100644
--- a/main.c
+++ b/main.c
@@ -38,6 +38,7 @@
#include <sdk/softdevice/s130/headers/nrf_soc.h>
#include <sdk/libraries/util/app_error.h>
#include <sdk/drivers_nrf/hal/nrf_gpio.h>
+#include <sdk/drivers_nrf/uart/app_uart.h>
#include <sdk/device/nrf51_bitfields.h>
#include <sdk/softdevice/s130/headers/ble.h>
#include <sdk/device/nrf51.h>
@@ -71,6 +72,8 @@
#define SCHED_QUEUE_SIZE 20 /**< Maximum number of events in the scheduler queue. */
+uint16_t m_uart_id; /** UART id returned from the UART module when calling app_uart_init, this id is kept, as it must be provided to the UART module when calling app_uart_close. */
+
/**@brief Callback function for asserts in the SoftDevice.
*
@@ -180,6 +183,49 @@ static void scheduler_init(void)
}
+static void uart_eventhandler(app_uart_evt_t * uart_event)
+{
+}
+
+void blart(char c)
+{
+if (c=='\n')
+ while (app_uart_put((uint8_t) '\r')==NRF_ERROR_NO_MEM);
+while (app_uart_put((uint8_t) c)==NRF_ERROR_NO_MEM);
+}
+
+void blarts(char *c)
+{
+while (*c)
+blart(*(c++));
+}
+
+
+static uint32_t uart_init(void)
+{
+ uint32_t err_code;
+
+ app_uart_comm_params_t comm_params =
+ {
+ RX_PIN_NUMBER,
+ TX_PIN_NUMBER,
+ RTS_PIN_NUMBER,
+ CTS_PIN_NUMBER,
+ APP_UART_FLOW_CONTROL_DISABLED,
+ false,
+ UART_BAUDRATE_BAUDRATE_Baud115200
+ };
+
+ err_code = app_uart_init(&comm_params,
+ NULL,
+ uart_eventhandler,
+ APP_IRQ_PRIORITY_LOW,
+ &m_uart_id);
+ return err_code;
+}
+
+
+
/**@brief Function for bootloader main entry.
*/
int main(void)
@@ -194,6 +240,10 @@ int main(void)
}
leds_init();
+ uart_init();
+
+ blarts("Hello world\n");
+
// This check ensures that the defined fields in the bootloader corresponds with actual
// setting in the nRF51 chip.