From c22372c5fab3a0e240a5e623f6e080cefbe35add Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Wed, 7 Nov 2018 01:50:27 -0800 Subject: Expose API in header file --- upload/upload.c | 10 +++++----- upload/upload.h | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 upload/upload.h diff --git a/upload/upload.c b/upload/upload.c index 494ed1b..90ea281 100644 --- a/upload/upload.c +++ b/upload/upload.c @@ -67,7 +67,7 @@ void retryInitSequence(FlashState* s) { configureSerialPort(s, MTK7697_BAUD); } -bool verifyInitSequence(FlashState* s) { +bool mtk_verifyInitSequence(FlashState* s) { uint8_t data; bool initDone = false; s->startTime = util_getUnixDatetime(); @@ -101,7 +101,7 @@ bool verifyInitSequence(FlashState* s) { bool flashBinary(FlashState* s, MtkMemorySegment segment, const char* binPath) { putIntoBootloader(); configureSerialPort(s, MTK7697_BAUD); - bool init = verifyInitSequence(s); + bool init = mtk_verifyInitSequence(s); LE_INFO("Init verified: %d", init); flashDa(s); configureSerialPort(s, MTK7697_BAUDX); @@ -165,17 +165,17 @@ void resetPins() { mtBootstrap_Deactivate(); } -void configureGpio() { +void mtk_configureGpio() { mtRst_SetPushPullOutput(MTRST_ACTIVE_HIGH, true); mtBootstrap_SetPushPullOutput(MTBOOTSTRAP_ACTIVE_HIGH, true); } -COMPONENT_INIT { +void mtk_init() { char path[1024]; snprintf(path, 1024, "/home/root/outputdata%d", util_getUnixDatetime()); outputFd = open(path, O_RDWR | O_CREAT); LE_INFO("Output fd %d", outputFd); - configureGpio(); + mtk_configureGpio(); flashLdr(&state); flashN9(&state); flashCm4(&state); diff --git a/upload/upload.h b/upload/upload.h new file mode 100644 index 0000000..9f4dd87 --- /dev/null +++ b/upload/upload.h @@ -0,0 +1,20 @@ +#ifndef MTK_UPLOAD_H +#define MTK_UPLOAD_H + +#define MTK7697_BAUD 115200 + +static const char* MTK_SERIAL_PORT_PATH = "/dev/ttyHS0"; + +typedef struct { + int serialPort; + int errorCount; + int cCount; + int retry; + int startTime; +} FlashState; + +bool mtk_verifyInitSequence(FlashState* s); + +void mtk_configureGpio(); + +#endif -- cgit v1.2.3