-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Serial USB functionality for debugging purposes
- Loading branch information
1 parent
f02bbf2
commit d450413
Showing
10 changed files
with
95 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
jewelbots_friendship_v112/cores/Jewelbot_v1/JWB_Serial.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
#include <stdarg.h> | ||
#include <stdio.h> | ||
#include <math.h> | ||
#include "Arduino.h" | ||
#include "JWB_Serial.h" | ||
#ifdef __cplusplus | ||
extern "C"{ | ||
#endif // __cplusplus | ||
#include "app_uart.h" | ||
#include "nrf.h" | ||
#include "nrf_log.h" | ||
#include "nrf_error.h" | ||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif // __cplusplus | ||
|
||
__INLINE void jwb_uart_write(const char * msg) | ||
{ | ||
while( *msg ) | ||
{ | ||
NRF_UART0->TXD = *msg++; | ||
while( NRF_UART0->EVENTS_TXDRDY != 1 ); | ||
NRF_UART0->EVENTS_TXDRDY = 0; | ||
} | ||
} | ||
|
||
void jwb_uart_write_many(int num_args, ...) | ||
{ | ||
const char* msg; | ||
va_list p_args; | ||
va_start(p_args, num_args); | ||
|
||
for (int i = 0; i < num_args; i++) | ||
{ | ||
msg = va_arg(p_args, const char*); | ||
jwb_uart_write(msg); | ||
} | ||
va_end(p_args); | ||
} | ||
|
||
void jwb_uart_printf(const char * format_msg, ...) | ||
{ | ||
static char buffer[256]; | ||
va_list p_args; | ||
va_start(p_args, format_msg); | ||
vsprintf(buffer, format_msg, p_args); | ||
va_end(p_args); | ||
jwb_uart_write(buffer); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef __JWB_SERIAL_H__ | ||
#define __JWB_SERIAL_H__ | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
#include <stdarg.h> | ||
#include <stdio.h> | ||
#include "Arduino.h" | ||
|
||
void jwb_uart_write(const char * str); | ||
void jwb_uart_write_many(int num_args, ...); | ||
void jwb_uart_printf(const char * format_msg, ...); | ||
|
||
#define JWB_SERIAL(...) jwb_uart_write_many(NUM_VA_ARGS(__VA_ARGS__), ##__VA_ARGS__) | ||
#define JWB_SERIAL_PRINTF(...) jwb_uart_printf(__VA_ARGS__) | ||
|
||
|
||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 0 additions & 53 deletions
53
jewelbots_friendship_v112/cores/Jewelbot_v1/nrf51_sdk/libraries/util/app_error_weak.c
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters