Feature/travis (#30)

* fix build warnings

* cmake build fixes and linux build files

* add travis build file
pull/35/head
Hans-Erik Floryd 2017-10-25 11:13:47 +02:00 committed by nakarlsson
parent 8dcbcb901f
commit 23d689dc63
11 changed files with 65 additions and 14 deletions

8
.travis.yml 100644
View File

@ -0,0 +1,8 @@
language: c
script:
- mkdir build
- pushd build
- cmake .. -DCMAKE_BUILD_TYPE=Release
- make
- popd

View File

@ -11,19 +11,23 @@ set (SOES_VERSION_PATCH 0)
# Generate version numbers
configure_file (
"${SOES_SOURCE_DIR}/version.h.in"
"${SOES_SOURCE_DIR}/soes/version.h"
${SOES_SOURCE_DIR}/version.h.in
${SOES_SOURCE_DIR}/soes/version.h
)
# Include paths
include_directories("${SOES_SOURCE_DIR}/soes")
include_directories(
${SOES_SOURCE_DIR}
${SOES_SOURCE_DIR}/soes
)
# Platform flags and sources
include(${CMAKE_SYSTEM_NAME} OPTIONAL)
# Source paths
add_subdirectory (soes)
add_subdirectory (applications/rtl_slavedemo)
add_subdirectory (${SOES_DEMO})
message (STATUS "Building for ${CMAKE_SYSTEM_NAME}")

View File

@ -1,5 +1,6 @@
Simple Open Source EtherCAT Slave
====
[![Build Status](https://travis-ci.org/OpenEtherCATsociety/SOES.svg?branch=master)](https://travis-ci.org/OpenEtherCATsociety/SOES)
SOES (Simple OpenSource EtherCAT Slave Stack) is an opensource slave
stack that is very easy to use and provides a small footprint. It is a

View File

@ -0,0 +1,7 @@
add_executable (demo
main.c
slave.c
slave_objectlist.c
)
target_link_libraries(demo LINK_PUBLIC soes)

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include "slave.h"
/**
* This function reads physical input values and assigns the corresponding members

View File

@ -56,4 +56,8 @@ typedef struct
uint32_t reset_counter;
} _Cbuffer;
extern _Rbuffer Rb;
extern _Wbuffer Wb;
extern _Cbuffer Cb;
#endif

14
cmake/Linux.cmake 100644
View File

@ -0,0 +1,14 @@
set(SOES_DEMO applications/linux_lan9252demo)
include_directories(
${SOES_SOURCE_DIR}/soes/include/sys/gcc
${SOES_SOURCE_DIR}/${SOES_DEMO}
)
set(HAL_SOURCES
${SOES_SOURCE_DIR}/soes/hal/linux-lan9252/esc_hw.c
)
# Common compile flags
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Werror)

View File

@ -18,6 +18,7 @@ include_directories(
${RTK}/include/arch/${ARCH}
${RTK}/include/kern
${RTK}/include/drivers
${RTK}/lwip/src/include
${RTK}/bsp/${BSP}/include
${SOES_SOURCE_DIR}/soes/include/sys/gcc
)

View File

@ -16,6 +16,12 @@ set(CPU cortex-m4f)
set(BSP twrk60f)
set(MACHINE_FLAGS "-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16")
set(SOES_DEMO applications/rtl_slavedemo)
include_directories(
${SOES_SOURCE_DIR}/${SOES_DEMO}
)
set(HAL_SOURCES
${SOES_SOURCE_DIR}/soes/hal/rt-kernel-twrk60/esc_hw.c
)

View File

@ -39,6 +39,7 @@
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#define BIT(x) 1 << (x)
@ -83,6 +84,7 @@ static int lan9252 = -1;
static void lan9252_write_32 (uint16_t address, uint32_t val)
{
uint8_t data[7];
int n;
data[0] = ESC_CMD_SERIAL_WRITE;
data[1] = ((address >> 8) & 0xFF);
@ -93,7 +95,8 @@ static void lan9252_write_32 (uint16_t address, uint32_t val)
data[6] = ((val >> 24) & 0xFF);
/* Write data */
write (lan9252, data, sizeof(data));
n = write (lan9252, data, sizeof(data));
(void)n;
}
/* lan9252 single read */
@ -102,13 +105,15 @@ static uint32_t lan9252_read_32 (uint32_t address)
uint8_t data[2];
uint8_t result[4];
uint16_t lseek_addr;
int n;
data[0] = ((address >>8) & 0xFF);
data[1] = (address & 0xFF);
lseek_addr=((uint16_t)data[0] << 8) | data[1];
lseek (lan9252, lseek_addr, SEEK_SET);
read (lan9252, result, sizeof(result));
n = read (lan9252, result, sizeof(result));
(void)n;
return ((result[3] << 24) |
(result[2] << 16) |
@ -155,11 +160,12 @@ static void ESC_read_pram (uint16_t address, void *buf, uint16_t len)
uint32_t value;
uint8_t * temp_buf = buf;
uint16_t byte_offset = 0;
uint8_t fifo_cnt, first_byte_position, temp_len, data[2];
uint8_t fifo_cnt, first_byte_position, temp_len;
uint8_t *buffer;
int i, array_size, size;
float quotient,remainder;
uint32_t temp;
int n;
value = ESC_PRAM_CMD_ABORT;
lan9252_write_32(ESC_PRAM_RD_CMD_REG, value);
@ -215,7 +221,8 @@ static void ESC_read_pram (uint16_t address, void *buf, uint16_t len)
memset(buffer,0,size);
lseek (lan9252, ESC_PRAM_RD_FIFO_REG, SEEK_SET);
read (lan9252, buffer, size);
n = read (lan9252, buffer, size);
(void)n;
while(len > 0)
{
@ -240,10 +247,11 @@ static void ESC_write_pram (uint16_t address, void *buf, uint16_t len)
uint32_t value;
uint8_t * temp_buf = buf;
uint16_t byte_offset = 0;
uint8_t fifo_cnt, first_byte_position, temp_len, data[3];
uint8_t fifo_cnt, first_byte_position, temp_len;
uint8_t *buffer;
int i, array_size, size;
float quotient,remainder;
int n;
value = ESC_PRAM_CMD_ABORT;
lan9252_write_32(ESC_PRAM_WR_CMD_REG, value);
@ -317,7 +325,8 @@ static void ESC_write_pram (uint16_t address, void *buf, uint16_t len)
byte_offset += temp_len;
}
}
write (lan9252, buffer, size);
n = write (lan9252, buffer, size);
(void)n;
free(buffer);
}
}

View File

@ -101,8 +101,6 @@ void ESC_read (uint16_t address, void *buf, uint16_t len)
/* Un-select device. */
spi_unselect (et1100);
/* result is never used */
return 0;
}
/** ESC write function used by the Slave stack.
@ -121,8 +119,6 @@ void ESC_write (uint16_t address, void *buf, uint16_t len)
write (et1100, buf, len);
/* Un-select device. */
spi_unselect (et1100);
/* result is never used */
return 0;
}
void ESC_reset (void)