Nordic Semiconductor nRF5 AirFuel SDK  version 2.2.0
app_print.c
Go to the documentation of this file.
1 /* Copyright (c) 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 
15 #include <string.h>
16 #include <stdio.h>
17 
18 #include "simple_uart.h"
19 #include "app_print.h"
20 
25 void print_string(char * char_array)
26 {
27  int size = strlen(char_array);
28 
29  while (size > 0)
30  {
31  size--;
32  simple_uart_put(*char_array);
33  char_array++;
34  }
35 }
36 
42 void print_hex(uint32_t number, uint8_t byte_size)
43 {
44  int i;
45  char hex_to_char[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
46 
47  for (i = ((byte_size*8)-4); i >= 0; i=i-4)
48  {
49  simple_uart_put((uint8_t)hex_to_char[number >> i & 0x0F]);
50  }
51 }
52 
61 void print_file_and_line(uint16_t line_num, const uint8_t *file_name)
62 {
63  char string[100];
64  (void)sprintf(string,"Line: %04d, File: %s",line_num, file_name);
65  print_string(string);
66 }
void print_file_and_line(uint16_t line_num, const uint8_t *file_name)
Function used to report event related to source code.
Definition: app_print.c:61
void simple_uart_put(uint8_t cr)
Function for sending a character to UART. Execution is blocked until UART peripheral reports characte...
Definition: simple_uart.c:62
void print_hex(uint32_t number, uint8_t byte_size)
Converts hex number into char and send it through UART TX.
Definition: app_print.c:42
void print_string(char *char_array)
Decomposes char array and send chars through UART TX.
Definition: app_print.c:25
Simple UART driver.