|
|
@ -1,9 +1,27 @@ |
|
|
|
#include "public_board.hpp"
|
|
|
|
|
|
|
|
#include "idtable/IdMgr.hpp"
|
|
|
|
#include "project_configs.h"
|
|
|
|
using namespace iflytop; |
|
|
|
using namespace transmit_disfection_protocol; |
|
|
|
|
|
|
|
static ZGPIO BID0; |
|
|
|
static ZGPIO BID1; |
|
|
|
static ZGPIO BID2; |
|
|
|
static ZGPIO BID3; |
|
|
|
static ZGPIO BID4; |
|
|
|
static ZGPIO BID5; |
|
|
|
static ZGPIO BID6; |
|
|
|
static ZGPIO BID7; |
|
|
|
|
|
|
|
int32_t getDeviceIdFromFlash() { |
|
|
|
int32_t *deviceId = (int32_t *)BOARD_TYPE_ID_FLASH_ADD; |
|
|
|
if (*deviceId <= 0) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
return *deviceId; |
|
|
|
} |
|
|
|
|
|
|
|
void PublicBoard::debugUartInit(void) { |
|
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0}; |
|
|
|
|
|
|
@ -74,12 +92,38 @@ void PublicBoard::initialize() { |
|
|
|
debugUartInit(); |
|
|
|
canInit(); |
|
|
|
|
|
|
|
if (getDeviceIdFromFlash() <= 0) { |
|
|
|
BID0.initAsInput(PE1, kxs_gpio_pullup, kxs_gpio_no_irq, false); |
|
|
|
BID1.initAsInput(PE2, kxs_gpio_pullup, kxs_gpio_no_irq, false); |
|
|
|
BID2.initAsInput(PE3, kxs_gpio_pullup, kxs_gpio_no_irq, false); |
|
|
|
BID3.initAsInput(PE4, kxs_gpio_pullup, kxs_gpio_no_irq, false); |
|
|
|
BID4.initAsInput(PE5, kxs_gpio_pullup, kxs_gpio_no_irq, false); |
|
|
|
BID5.initAsInput(PE6, kxs_gpio_pullup, kxs_gpio_no_irq, false); |
|
|
|
BID6.initAsInput(PE7, kxs_gpio_pullup, kxs_gpio_no_irq, false); |
|
|
|
BID7.initAsInput(PE8, kxs_gpio_pullup, kxs_gpio_no_irq, false); |
|
|
|
} |
|
|
|
|
|
|
|
m_debugled.initAsOutput(DEBUG_LIGHT_GPIO, kxs_gpio_nopull, false, false); |
|
|
|
} |
|
|
|
|
|
|
|
void PublicBoard::setDebugLightState(bool state) { m_debugled.write(state); } |
|
|
|
void PublicBoard::toggleDebugLight() { m_debugled.toggle(); } |
|
|
|
|
|
|
|
int PublicBoard::getProjId() { return klarge_space_disinfection_machine; } |
|
|
|
int PublicBoard::getBoardTypeId() { return kLargeSpaceDMLiquidCtrlBoard; } |
|
|
|
int PublicBoard::getProjId() { return IdMgr::ins().getProjId(getBoardTypeId()); } |
|
|
|
int PublicBoard::getBoardTypeId() { |
|
|
|
if (getDeviceIdFromFlash() > 0) { |
|
|
|
return getDeviceIdFromFlash(); |
|
|
|
} else { |
|
|
|
int32_t id = 0; |
|
|
|
id += BID0.read() ? 1 : 0; |
|
|
|
id += BID1.read() ? 2 : 0; |
|
|
|
id += BID2.read() ? 4 : 0; |
|
|
|
id += BID3.read() ? 8 : 0; |
|
|
|
id += BID4.read() ? 16 : 0; |
|
|
|
id += BID5.read() ? 32 : 0; |
|
|
|
id += BID6.read() ? 64 : 0; |
|
|
|
id += BID7.read() ? 128 : 0; |
|
|
|
return id; |
|
|
|
} |
|
|
|
} |
|
|
|
int PublicBoard::getBoardId() { return IdMgr::ins().getBoardId(getBoardTypeId()); } |