2015-06-16 00:02:36 +00:00
|
|
|
/*
|
2015-10-06 12:48:28 +00:00
|
|
|
* Compatibility routines for the Espressif SDK and its API
|
2015-06-16 00:02:36 +00:00
|
|
|
*
|
|
|
|
* Part of esp-open-rtos
|
|
|
|
* Copyright (C) 2015 Superhouse Automation Pty Ltd
|
|
|
|
* BSD Licensed as described in the file LICENSE
|
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2015-07-29 00:34:09 +00:00
|
|
|
#include <common_macros.h>
|
2015-06-16 00:02:36 +00:00
|
|
|
|
2015-10-06 12:48:28 +00:00
|
|
|
#include <esp/uart.h>
|
|
|
|
|
2015-07-29 00:34:09 +00:00
|
|
|
void IRAM *zalloc(size_t nbytes)
|
2015-06-16 00:02:36 +00:00
|
|
|
{
|
|
|
|
return calloc(1, nbytes);
|
|
|
|
}
|
2015-08-10 05:51:57 +00:00
|
|
|
|
|
|
|
extern void (*__init_array_start)(void);
|
|
|
|
extern void (*__init_array_end)(void);
|
|
|
|
|
2015-10-06 12:48:28 +00:00
|
|
|
/* Do things which should be done as part of the SDK startup code, but aren't.
|
|
|
|
TODO: Move into app_main.c
|
2015-08-10 05:51:57 +00:00
|
|
|
*/
|
|
|
|
void sdk_compat_initialise()
|
|
|
|
{
|
|
|
|
/* Call C++ constructors or C functions marked with __attribute__((constructor)) */
|
|
|
|
void (**p)(void);
|
|
|
|
for ( p = &__init_array_start; p != &__init_array_end; ++p)
|
|
|
|
(*p)();
|
|
|
|
}
|
2015-10-06 12:48:28 +00:00
|
|
|
|
|
|
|
/* UART RX function from Espressif SDK internals.
|
|
|
|
*
|
|
|
|
* Not part of published API.
|
|
|
|
*/
|
|
|
|
int sdk_uart_rx_one_char(char *buf) {
|
|
|
|
int c = uart_getc_nowait(0);
|
|
|
|
if(c < 0)
|
|
|
|
return 1;
|
|
|
|
*buf = (char)c;
|
|
|
|
return 0;
|
|
|
|
}
|