diff options
| author | Aditya Naik | 2020-08-05 12:07:53 -0400 |
|---|---|---|
| committer | Aditya Naik | 2020-08-05 12:07:53 -0400 |
| commit | 6fc56b1dfe07bebe4184a8cecbfbd3c50466bfe0 (patch) | |
| tree | 94761159de5c488832056a1142ff3a59e716cb0e | |
| parent | 5154fdecac5260ea3a2fd6416c1186eb4d609449 (diff) | |
Changes and stuff
| -rw-r--r-- | include/main.h | 2 | ||||
| -rw-r--r-- | include/stream.h | 13 | ||||
| -rw-r--r-- | ports/posix/makefile | 3 | ||||
| -rw-r--r-- | ports/posix/src/port.h | 3 | ||||
| -rw-r--r-- | src/master_posix.c | 16 | ||||
| -rw-r--r-- | src/master_rtos.c | 6 |
6 files changed, 35 insertions, 8 deletions
diff --git a/include/main.h b/include/main.h index 60fe0a2..d344c63 100644 --- a/include/main.h +++ b/include/main.h @@ -16,8 +16,6 @@ extern "C" { #include "port.h"
void Error_Handler(void);
-
-#define BUS_DEVICE_LIMIT 16
#ifdef __cplusplus
}
diff --git a/include/stream.h b/include/stream.h index 96d9823..73b3daa 100644 --- a/include/stream.h +++ b/include/stream.h @@ -1,7 +1,16 @@ #include <stdint.h> #include <stddef.h> -/* typedef struct p_stream_s p_stream_t; */ +#ifndef __STREAM_H +#define __STREAM_H +/* + * Struct for abstract stream + * + * Stream properties: generalized variables for individual devices + * props[0]: Peripheral device (fd, hi2c, huart, and so on) + * props[1]: Bus device ID + * + */ typedef struct { int (*read)(uint8_t *buf, size_t len, void **vptr, void *sptr); @@ -9,3 +18,5 @@ typedef struct { int (*init)(void **vptr, void *sptr); void **props; } p_stream_t; + +#endif diff --git a/ports/posix/makefile b/ports/posix/makefile index 91e0792..6b9367e 100644 --- a/ports/posix/makefile +++ b/ports/posix/makefile @@ -10,4 +10,5 @@ C_INCLUDES += \ C_SOURCES += \ lib/FreeRTOS/FreeRTOS/Source/portable/ThirdParty/GCC/Posix/port.c \ -ports/posix/src/stream_stdio.c +ports/posix/src/stream_stdio.c \ +ports/posix/src/port_devices.c diff --git a/ports/posix/src/port.h b/ports/posix/src/port.h index 01d1fb1..6f10699 100644 --- a/ports/posix/src/port.h +++ b/ports/posix/src/port.h @@ -11,5 +11,8 @@ #include <mqueue.h> #include <stdint.h> #include <errno.h> +#include "stream.h" + +int initialize_devices(int num_devices, p_stream_t *streams); #endif diff --git a/src/master_posix.c b/src/master_posix.c index 83eb741..c312757 100644 --- a/src/master_posix.c +++ b/src/master_posix.c @@ -28,6 +28,7 @@ #include "data.pb.h" #include "stream.h" #include "stream_stdio.h" +#include "port.h" /* FreeRTOS+POSIX. should go in the port folder */ /* #include "FreeRTOS_POSIX/pthread.h" */ @@ -45,7 +46,7 @@ #define SET_BIT_FROM_IDX(a, b) a[b>>5]|=(1<<(b%32)) #define COUNTOF(__BUFFER__) (sizeof(__BUFFER__) / sizeof(*(__BUFFER__))) -#define BUS_DEVICE_LIMIT 16 +#define BUS_DEVICE_LIMIT 2 device_info_t *device_info[BUS_DEVICE_LIMIT] = {NULL}; subscription_info_t* subs_info[BUS_DEVICE_LIMIT]; @@ -101,6 +102,17 @@ void vStartPOSIXMaster(void *pvParams) pthread_create(&routing_thread, NULL, routing_func, NULL); + /* This function will be defined for the port + * Each port will have a configuration file that includes details about the bus, + * either in a custom format or in a devicetree format (preferred) + * + */ + + p_stream_t *device_streams; + device_streams = malloc(sizeof(p_stream_t)*BUS_DEVICE_LIMIT); + + initialize_devices(BUS_DEVICE_LIMIT, device_streams); + /* Add device-specific stream/thread declerations here, if needed */ /* ... */ @@ -147,6 +159,8 @@ static void *routing_func(void *pvArgs) } return NULL; } + +/* This function should go into its own file, with a normalized state machine implementation */ hs_status_t handshake(uint32_t i2c_addr) { diff --git a/src/master_rtos.c b/src/master_rtos.c index 4ca3461..27a78b8 100644 --- a/src/master_rtos.c +++ b/src/master_rtos.c @@ -3,7 +3,7 @@ #include "task.h" /* System headers */ -#include <stdio.h> +/* #include <stdio.h> */ /* Master include */ #include "master_posix.h" @@ -54,8 +54,8 @@ void vAssertCalled(const char * pcFile, (void) pcFileName; (void) ulLineNumber; - printf("vAssertCalled %s, %ld\n", pcFile, (long) ulLine); - fflush(stdout); + /* printf("vAssertCalled %s, %ld\n", pcFile, (long) ulLine); */ + /* fflush(stdout); */ /* Setting ulBlockVariable to a non-zero value in the debugger will allow * this function to be exited. */ |
