From 6873b17117a41715c9a8ca63060974b64b4cdcf4 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 21 Feb 2016 23:17:59 +0200 Subject: [PATCH] Support for Chibios compilation Remove some warnings, change the include paths. --- serial_link.mk | 3 ++- serial_link/protocol/byte_stuffer.c | 8 ++++---- serial_link/protocol/byte_stuffer.h | 7 +++++++ serial_link/protocol/frame_router.c | 5 +++-- serial_link/protocol/frame_router.h | 8 ++++++++ serial_link/protocol/frame_validator.c | 7 ++++--- serial_link/protocol/frame_validator.h | 7 +++++++ serial_link/protocol/physical.h | 5 +++++ serial_link/protocol/transport.c | 20 +++++++++---------- serial_link/protocol/transport.h | 5 ++--- serial_link/protocol/triple_buffered_object.c | 6 ++++-- serial_link/protocol/triple_buffered_object.h | 2 ++ serial_link/system/system.h | 12 ++++++++--- serial_link/tests/Makefile | 2 +- serial_link/tests/byte_stuffer_tests.c | 8 ++++---- serial_link/tests/frame_router_tests.c | 8 ++++---- serial_link/tests/frame_validator_tests.c | 2 +- serial_link/tests/transport_tests.c | 4 ++-- .../tests/triple_buffered_object_tests.c | 2 +- 19 files changed, 79 insertions(+), 42 deletions(-) diff --git a/serial_link.mk b/serial_link.mk index de2364108..e8915a33f 100644 --- a/serial_link.mk +++ b/serial_link.mk @@ -20,4 +20,5 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -INC += $(SERIAL_DIR) \ No newline at end of file +INC += $(SERIAL_DIR) +SRC += $(wildcard $(SERIAL_DIR)/serial_link/protocol/*.c) \ No newline at end of file diff --git a/serial_link/protocol/byte_stuffer.c b/serial_link/protocol/byte_stuffer.c index 8b529667f..fb4c45a8d 100644 --- a/serial_link/protocol/byte_stuffer.c +++ b/serial_link/protocol/byte_stuffer.c @@ -22,10 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "protocol/byte_stuffer.h" -#include "protocol/frame_validator.h" -#include "protocol/physical.h" -#include +#include "serial_link/protocol/byte_stuffer.h" +#include "serial_link/protocol/frame_validator.h" +#include "serial_link/protocol/physical.h" +#include // This implements the "Consistent overhead byte stuffing protocol" // https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing diff --git a/serial_link/protocol/byte_stuffer.h b/serial_link/protocol/byte_stuffer.h index 839a876fe..2cc88beb4 100644 --- a/serial_link/protocol/byte_stuffer.h +++ b/serial_link/protocol/byte_stuffer.h @@ -22,6 +22,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef SERIAL_LINK_BYTE_STUFFER_H +#define SERIAL_LINK_BYTE_STUFFER_H + +#include + void init_byte_stuffer(void); void byte_stuffer_recv_byte(uint8_t link, uint8_t data); void byte_stuffer_send_frame(uint8_t link, uint8_t* data, uint16_t size); + +#endif diff --git a/serial_link/protocol/frame_router.c b/serial_link/protocol/frame_router.c index 890ebbe9e..04b8c2e75 100644 --- a/serial_link/protocol/frame_router.c +++ b/serial_link/protocol/frame_router.c @@ -22,8 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "protocol/frame_router.h" -#include "protocol/transport.h" +#include "serial_link/protocol/frame_router.h" +#include "serial_link/protocol/transport.h" +#include "serial_link/protocol/frame_validator.h" static bool is_master; diff --git a/serial_link/protocol/frame_router.h b/serial_link/protocol/frame_router.h index 67db3122f..712250ff3 100644 --- a/serial_link/protocol/frame_router.h +++ b/serial_link/protocol/frame_router.h @@ -22,9 +22,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef SERIAL_LINK_FRAME_ROUTER_H +#define SERIAL_LINK_FRAME_ROUTER_H + +#include +#include + #define UP_LINK 0 #define DOWN_LINK 1 void router_set_master(bool master); void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size); void router_send_frame(uint8_t destination, uint8_t* data, uint16_t size); + +#endif diff --git a/serial_link/protocol/frame_validator.c b/serial_link/protocol/frame_validator.c index a3face650..474f80ee8 100644 --- a/serial_link/protocol/frame_validator.c +++ b/serial_link/protocol/frame_validator.c @@ -22,9 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "protocol/frame_validator.h" -#include "protocol/frame_router.h" -#include "protocol/byte_stuffer.h" +#include "serial_link/protocol/frame_validator.h" +#include "serial_link/protocol/frame_router.h" +#include "serial_link/protocol/byte_stuffer.h" +#include const uint32_t poly8_lookup[256] = { diff --git a/serial_link/protocol/frame_validator.h b/serial_link/protocol/frame_validator.h index c35fc2726..4a910d510 100644 --- a/serial_link/protocol/frame_validator.h +++ b/serial_link/protocol/frame_validator.h @@ -22,6 +22,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef SERIAL_LINK_FRAME_VALIDATOR_H +#define SERIAL_LINK_FRAME_VALIDATOR_H + +#include + void validator_recv_frame(uint8_t link, uint8_t* data, uint16_t size); // The buffer pointed to by the data needs 4 additional bytes void validator_send_frame(uint8_t link, uint8_t* data, uint16_t size); + +#endif diff --git a/serial_link/protocol/physical.h b/serial_link/protocol/physical.h index ee5883d36..425e06cdd 100644 --- a/serial_link/protocol/physical.h +++ b/serial_link/protocol/physical.h @@ -22,4 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef SERIAL_LINK_PHYSICAL_H +#define SERIAL_LINK_PHYSICAL_H + void send_data(uint8_t link, const uint8_t* data, uint16_t size); + +#endif diff --git a/serial_link/protocol/transport.c b/serial_link/protocol/transport.c index 03f83a806..4542a7a05 100644 --- a/serial_link/protocol/transport.c +++ b/serial_link/protocol/transport.c @@ -22,9 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "protocol/transport.h" -#include "protocol/frame_router.h" -#include "protocol/triple_buffered_object.h" +#include "serial_link/protocol/transport.h" +#include "serial_link/protocol/frame_router.h" +#include "serial_link/protocol/triple_buffered_object.h" +#include static remote_object_t** remote_objects; static uint32_t num_remote_objects; @@ -32,7 +33,7 @@ static uint32_t num_remote_objects; void init_transport(remote_object_t** _remote_objects, uint32_t _num_remote_objects) { remote_objects = _remote_objects; num_remote_objects = _num_remote_objects; - int i; + unsigned int i; for(i=0;iobject_type == MASTER_TO_ALL_SLAVES) { @@ -44,7 +45,7 @@ void init_transport(remote_object_t** _remote_objects, uint32_t _num_remote_obje } else if(obj->object_type == MASTER_TO_SINGLE_SLAVE) { uint8_t* start = obj->buffer; - int j; + unsigned int j; for (j=0;jobject_size); - int j; + unsigned int j; for (j=0;jobject_type == MASTER_TO_ALL_SLAVES || obj->object_type == SLAVE_TO_MASTER) { @@ -106,7 +104,7 @@ void update_transport(void) { } else { uint8_t* start = obj->buffer; - int j; + unsigned int j; for (j=0;jobject_size + LOCAL_OBJECT_EXTRA, tb); diff --git a/serial_link/protocol/transport.h b/serial_link/protocol/transport.h index a1a83b8f7..9e9e22462 100644 --- a/serial_link/protocol/transport.h +++ b/serial_link/protocol/transport.h @@ -25,8 +25,8 @@ SOFTWARE. #ifndef SERIAL_LINK_TRANSPORT_H #define SERIAL_LINK_TRANSPORT_H -#include "protocol/triple_buffered_object.h" -#include "system/system.h" +#include "serial_link/protocol/triple_buffered_object.h" +#include "serial_link/system/system.h" #define NUM_SLAVES 8 #define LOCAL_OBJECT_EXTRA 16 @@ -146,7 +146,6 @@ typedef struct { \ void init_transport(remote_object_t** remote_objects, uint32_t num_remote_objects); void transport_recv_frame(uint8_t from, uint8_t* data, uint16_t size); -uint32_t transport_send_frame(uint8_t to, uint8_t* data, uint16_t size); void update_transport(void); #endif diff --git a/serial_link/protocol/triple_buffered_object.c b/serial_link/protocol/triple_buffered_object.c index 6b3cf75ad..c6bf28af0 100644 --- a/serial_link/protocol/triple_buffered_object.c +++ b/serial_link/protocol/triple_buffered_object.c @@ -22,8 +22,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "protocol/triple_buffered_object.h" -#include "system/system.h" +#include "serial_link/protocol/triple_buffered_object.h" +#include "serial_link/system/system.h" +#include +#include #define GET_READ_INDEX() object->state & 3 #define GET_WRITE_INDEX() (object->state >> 2) & 3 diff --git a/serial_link/protocol/triple_buffered_object.h b/serial_link/protocol/triple_buffered_object.h index 03209709c..2e57db3f5 100644 --- a/serial_link/protocol/triple_buffered_object.h +++ b/serial_link/protocol/triple_buffered_object.h @@ -25,6 +25,8 @@ SOFTWARE. #ifndef SERIAL_LINK_TRIPLE_BUFFERED_OBJECT_H #define SERIAL_LINK_TRIPLE_BUFFERED_OBJECT_H +#include + typedef struct { uint8_t state; uint8_t buffer[] __attribute__((aligned(4))); diff --git a/serial_link/system/system.h b/serial_link/system/system.h index 163349953..1e4c610b1 100644 --- a/serial_link/system/system.h +++ b/serial_link/system/system.h @@ -25,12 +25,18 @@ SOFTWARE. #ifndef SERIAL_LINK_SYSTEM_H #define SERIAL_LINK_SYSTEM_H -void serial_link_lock() { +inline void serial_link_lock(void) { } -void serial_link_unlock() { +inline void serial_link_unlock(void) { } -void signal_data_written(void); +void singal_data_written(void); + +#if defined(PROTOCOL_CHIBIOS) + +inline void signal_data_written(void) { +} +#endif #endif diff --git a/serial_link/tests/Makefile b/serial_link/tests/Makefile index 0d8ba4b7b..1b072c6f1 100644 --- a/serial_link/tests/Makefile +++ b/serial_link/tests/Makefile @@ -22,7 +22,7 @@ CC = gcc CFLAGS = -INCLUDES = -I. -I../ +INCLUDES = -I. -I../../ LDFLAGS = -L$(BUILDDIR)/cgreen/build-c/src -shared LDLIBS = -lcgreen UNITOBJ = $(BUILDDIR)/serialtest/unitobj diff --git a/serial_link/tests/byte_stuffer_tests.c b/serial_link/tests/byte_stuffer_tests.c index 912c4d321..64b170e8c 100644 --- a/serial_link/tests/byte_stuffer_tests.c +++ b/serial_link/tests/byte_stuffer_tests.c @@ -24,10 +24,10 @@ SOFTWARE. #include #include -#include "protocol/byte_stuffer.h" -#include "protocol/byte_stuffer.c" -#include "protocol/frame_validator.h" -#include "protocol/physical.h" +#include "serial_link/protocol/byte_stuffer.h" +#include "serial_link/protocol/byte_stuffer.c" +#include "serial_link/protocol/frame_validator.h" +#include "serial_link/protocol/physical.h" static uint8_t sent_data[MAX_FRAME_SIZE*2]; static uint16_t sent_data_size; diff --git a/serial_link/tests/frame_router_tests.c b/serial_link/tests/frame_router_tests.c index 0b0ea6e7f..6c806fa93 100644 --- a/serial_link/tests/frame_router_tests.c +++ b/serial_link/tests/frame_router_tests.c @@ -24,10 +24,10 @@ SOFTWARE. #include #include -#include "protocol/byte_stuffer.c" -#include "protocol/frame_validator.c" -#include "protocol/frame_router.c" -#include "protocol/transport.h" +#include "serial_link/protocol/byte_stuffer.c" +#include "serial_link/protocol/frame_validator.c" +#include "serial_link/protocol/frame_router.c" +#include "serial_link/protocol/transport.h" static uint8_t received_data[256]; static uint16_t received_data_size; diff --git a/serial_link/tests/frame_validator_tests.c b/serial_link/tests/frame_validator_tests.c index f4abd14d1..d20947e2c 100644 --- a/serial_link/tests/frame_validator_tests.c +++ b/serial_link/tests/frame_validator_tests.c @@ -24,7 +24,7 @@ SOFTWARE. #include #include -#include "protocol/frame_validator.c" +#include "serial_link/protocol/frame_validator.c" void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size) { mock(data, size); diff --git a/serial_link/tests/transport_tests.c b/serial_link/tests/transport_tests.c index 3fa8eab4a..3e9bffdfa 100644 --- a/serial_link/tests/transport_tests.c +++ b/serial_link/tests/transport_tests.c @@ -24,8 +24,8 @@ SOFTWARE. #include #include -#include "protocol/transport.c" -#include "protocol/triple_buffered_object.c" +#include "serial_link/protocol/transport.c" +#include "serial_link/protocol/triple_buffered_object.c" void signal_data_written(void) { mock(); diff --git a/serial_link/tests/triple_buffered_object_tests.c b/serial_link/tests/triple_buffered_object_tests.c index 1017df8f5..6f7c82b46 100644 --- a/serial_link/tests/triple_buffered_object_tests.c +++ b/serial_link/tests/triple_buffered_object_tests.c @@ -23,7 +23,7 @@ SOFTWARE. */ #include -#include "protocol/triple_buffered_object.c" +#include "serial_link/protocol/triple_buffered_object.c" typedef struct { uint8_t state;