fix rt-kernel build

pull/51/head
Hans-Erik Floryd 2019-01-17 17:38:46 +01:00
parent edcce5af0f
commit bdb212942b
3 changed files with 13 additions and 6 deletions

View File

@ -41,7 +41,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MACHINE_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MACHINE_FLAGS}" CACHE STRING "" FORCE)
# Default libs
set(RTK_LIBS "-l${BSP} -l${ARCH} -lkern -ldev -lsio -lblock -lfs -lusb -llwip -lptpd -leth -li2c -lrtc -lcan -lnand -lspi -lnor -lpwm -ladc -ltrace -lcounter -lc -lm")
set(RTK_LIBS "-l${BSP} -l${ARCH} -lkern -ldev -lsio -lblock -lfs -lusb -llwip -lptpd -leth -li2c -lrtc -lcan -lnand -lspi -lnor -lpwm -ladc -ltrace -lcounter -lc -lm -lshell")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -nostartfiles -T${RTK}/bsp/${BSP}/${BSP}.ld -Wl,--start-group <LINK_LIBRARIES> ${RTK_LIBS} -Wl,--end-group")
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -nostartfiles -T${RTK}/bsp/${BSP}/${BSP}.ld -Wl,--start-group <LINK_LIBRARIES> ${RTK_LIBS} -Wl,--end-group")

View File

@ -16,6 +16,8 @@
#include <string.h>
#include <gpio.h>
#define MAX_READ_SIZE 128
#define ESC_CMD_READ 0x02
#define ESC_CMD_READWS 0x03
#define ESC_CMD_WRITE 0x04
@ -24,7 +26,7 @@
#define ESC_NEXT 0x00
static int et1100 = -1;
static uint8_t read_termination[MAX(sizeof(Wb), 128)] = { 0 };
static uint8_t read_termination[MAX_READ_SIZE] = { 0 };
#define GPIO_ECAT_RESET 1 /* specific function to hold ESC reset on startup
* when emulating EEPROM
@ -56,7 +58,7 @@ static void esc_address (uint16_t address, uint8_t command)
*/
void ESC_read (uint16_t address, void *buf, uint16_t len)
{
ASSERT(len <= sizeof(read_termination));
ASSERT(len <= MAX_READ_SIZE);
/* Select device. */
spi_select (et1100);
@ -69,7 +71,7 @@ void ESC_read (uint16_t address, void *buf, uint16_t len)
* Read (and write termination bytes).
*/
spi_bidirectionally_transfer (et1100, buf, read_termination +
(sizeof(read_termination) - len), len);
(MAX_READ_SIZE - len), len);
/* Un-select device. */
spi_unselect (et1100);
@ -122,5 +124,5 @@ void ESC_init (const esc_cfg_t * config)
{
const char * spi_name = (char *)config->user_arg;
et1100 = open (spi_name, O_RDWR, 0);
read_termination[sizeof(read_termination) - 1] = 0xFF;
read_termination[MAX_READ_SIZE - 1] = 0xFF;
}

View File

@ -33,7 +33,11 @@ extern "C"
#define CC_PACKED_END
#define CC_PACKED __attribute__((packed))
#ifdef __rtk__
#define CC_ASSERT(exp) ASSERT (exp)
#else
#define CC_ASSERT(exp) assert (exp)
#endif
#define CC_STATIC_ASSERT(exp) _Static_assert (exp, "")
#define CC_DEPRECATED __attribute__((deprecated))
@ -66,7 +70,8 @@ extern "C"
#endif
#ifdef ESC_DEBUG
#define DPRINT(...) rprintp ("esc_foe: "__VA_ARGS__) /* TODO */
#include <rprint.h>
#define DPRINT(...) rprintp ("soes: "__VA_ARGS__) /* TODO */
#else
#define DPRINT(...)
#endif /* DEBUG */