Skip to content

Commit

Permalink
FG: Use explicit macro for MCU ports.
Browse files Browse the repository at this point in the history
The current FG ctrl_api relies "STM32F469xx" macro to be defined for
MCU hosts without unistd and socket APIs. As this macro is implicitly
defined by STM projects when the target MCU is the same as the
discovery board (STM32F469I), this could be a issue if a different
MCU platform is used.
This patch make this selection clear by using a seperate macro defined in
"platform_wrapper.h", which can be defined by the user as required.

Signed-off-by: Yilin Sun <imi415@imi.moe>
  • Loading branch information
imi415 committed Dec 23, 2022
1 parent 77b5195 commit 3583fb7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions esp_hosted_fg/host/control_lib/src/ctrl_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <unistd.h>


#ifdef STM32F469xx
#ifdef MCU_SYS
#include "common.h"
#define command_log(...) printf(__VA_ARGS__); printf("\r");
#else
Expand All @@ -20,7 +20,7 @@
#define min(X, Y) (((X) < (Y)) ? (X) : (Y))
#endif

#ifndef STM32F469xx
#ifndef MCU_SYS
#define MAX_INTERFACE_LEN IFNAMSIZ
#define MAC_SIZE_BYTES 6
#define MIN_MAC_STR_LEN 17
Expand Down Expand Up @@ -160,7 +160,7 @@ static inline int is_ctrl_lib_state(int state)
}


#ifndef STM32F469xx
#ifndef MCU_SYS
/* Function converts mac string to byte stream */
static int convert_mac_to_bytes(uint8_t *out, size_t out_size, char *s)
{
Expand Down Expand Up @@ -1534,7 +1534,7 @@ int deinit_hosted_control_lib_internal(void)
int init_hosted_control_lib_internal(void)
{
int ret = SUCCESS;
#ifndef STM32F469xx
#ifndef MCU_SYS
if(getuid()) {
printf("Please re-run program with superuser access\n");
return FAILURE;
Expand Down Expand Up @@ -1582,7 +1582,7 @@ int init_hosted_control_lib_internal(void)



#ifndef STM32F469xx
#ifndef MCU_SYS

/* Function ups in given interface */
int interface_up(int sockfd, char* iface)
Expand Down
2 changes: 2 additions & 0 deletions esp_hosted_fg/host/stm32/port/include/platform_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <unistd.h>
#include <sys/types.h>

#define MCU_SYS 1

#define TIMEOUT_PSERIAL_RESP 30

#define CTRL__TIMER_ONESHOT 0
Expand Down
2 changes: 1 addition & 1 deletion esp_hosted_fg/host/virtual_serial_if/src/serial_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define PROTO_PSER_TLV_T_EPNAME 0x01
#define PROTO_PSER_TLV_T_DATA 0x02

#ifdef STM32F469xx
#ifdef MCU_SYS
#define command_log(format, ...) printf(format "\r", ##__VA_ARGS__);
#else
#define command_log(...) printf("%s:%u ",__func__,__LINE__); \
Expand Down

0 comments on commit 3583fb7

Please sign in to comment.