Remove assert code and add ascii table print
This commit is contained in:
parent
f1f06f056a
commit
a7a915faf4
29
src/main.c
29
src/main.c
@ -1,9 +1,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#define __ASSERT_USE_STDERR
|
|
||||||
#include <assert.h>
|
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
#include "print_helper.h"
|
||||||
|
|
||||||
#define BLINK_DELAY_MS 100
|
#define BLINK_DELAY_MS 100
|
||||||
|
|
||||||
@ -11,35 +10,23 @@ int main (void)
|
|||||||
{
|
{
|
||||||
/* set pin 3 of PORTA for output*/
|
/* set pin 3 of PORTA for output*/
|
||||||
DDRA |= _BV(DDA3);
|
DDRA |= _BV(DDA3);
|
||||||
/* Init error console as stderr in UART3 and print user code info */
|
/* Init stdio on UART0 and UART3 and print user code info */
|
||||||
|
uart0_init();
|
||||||
uart3_init();
|
uart3_init();
|
||||||
|
stdout = stdin = &uart0_io;
|
||||||
stderr = &uart3_out;
|
stderr = &uart3_out;
|
||||||
fprintf(stderr, "Version: %s built on: %s %s\n",
|
fprintf(stderr, "Version: %s built on: %s %s\n",
|
||||||
GIT_DESCR, __DATE__, __TIME__);
|
GIT_DESCR, __DATE__, __TIME__);
|
||||||
fprintf(stderr, "avr-libc version: %s\n", __AVR_LIBC_VERSION_STRING__);
|
fprintf(stderr, "avr-libc version: %s\n", __AVR_LIBC_VERSION_STRING__);
|
||||||
/*End UART3 init and info print */
|
/* End stdio init and info print */
|
||||||
/* Test assert - REMOVE IN FUTURE LABS */
|
|
||||||
char *array;
|
/* ASCII table print */
|
||||||
uint32_t i = 1;
|
print_ascii_tbl(stderr);
|
||||||
extern int __heap_start, *__brkval;
|
|
||||||
int v;
|
|
||||||
array = malloc( i * sizeof(char));
|
|
||||||
assert(array);
|
|
||||||
/* End test assert */
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* set pin 3 high to turn led on */
|
/* set pin 3 high to turn led on */
|
||||||
PORTA |= _BV(PORTA3);
|
PORTA |= _BV(PORTA3);
|
||||||
_delay_ms(BLINK_DELAY_MS);
|
_delay_ms(BLINK_DELAY_MS);
|
||||||
/* Test assert - REMOVE IN FUTURE LABS */
|
|
||||||
/* Increase memory allocated for array by 100 chars
|
|
||||||
* until we have eaten it all and print space between Stack and Heap.
|
|
||||||
* Thats how assert works in run-time */
|
|
||||||
array = realloc( array, (i++ * 100) * sizeof(char));
|
|
||||||
fprintf(stderr, "%d ",
|
|
||||||
(int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval));
|
|
||||||
assert(array);
|
|
||||||
/* End test assert */
|
|
||||||
/* set pin 3 low to turn led off */
|
/* set pin 3 low to turn led off */
|
||||||
PORTA &= ~_BV(PORTA3);
|
PORTA &= ~_BV(PORTA3);
|
||||||
_delay_ms(BLINK_DELAY_MS);
|
_delay_ms(BLINK_DELAY_MS);
|
||||||
|
Loading…
Reference in New Issue
Block a user