From 590f733ff93cb7326036cee42f4820a80c81b2af Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Fri, 9 Sep 2016 17:02:43 -0600 Subject: [PATCH] uart_ow: convert static const int MRAA_UART_OW_ROMCODE_SIZE to #define This is needed so that this value can be used in all places in C (and C++) code. Unlike C++ you can't always use a static const int variable to declare an array size for example. Trying to do so will yield compiler errors. In addition, during the declaration of the uart_ow_context, replace a hardcoded '8' with this macro. Originally, the '8' was hardcoded for this very reason. Signed-off-by: Jon Trulson Signed-off-by: Brendan Le Foll --- api/mraa/uart_ow.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/mraa/uart_ow.h b/api/mraa/uart_ow.h index 7cd098f..8551166 100644 --- a/api/mraa/uart_ow.h +++ b/api/mraa/uart_ow.h @@ -64,19 +64,19 @@ extern "C" { #include "common.h" #include "uart.h" +/* 8 bytes (64 bits) for a device rom code */ +#define MRAA_UART_OW_ROMCODE_SIZE 8 + /* for now, we simply use the normal MRAA UART context */ typedef struct _mraa_uart_ow { mraa_uart_context uart; /* search state */ - unsigned char ROM_NO[8]; /* 8 byte (64b) rom code */ + unsigned char ROM_NO[MRAA_UART_OW_ROMCODE_SIZE]; /* 8 byte (64b) rom code */ int LastDiscrepancy; int LastFamilyDiscrepancy; mraa_boolean_t LastDeviceFlag; } *mraa_uart_ow_context; -/* 8 bytes (64 bits) for a device rom code */ -static const int MRAA_UART_OW_ROMCODE_SIZE = 8; - /** * UART One Wire ROM related Command bytes */