Add interface test for stk500v2 library callbacks
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "clock.hpp"
|
||||
|
||||
#include "stk500v2.hpp"
|
||||
|
||||
#include "uart/uart.hpp"
|
||||
|
||||
#include <math.h>
|
||||
@@ -570,8 +572,62 @@ static inline void handleMessage(Message &msg, uint32_t &addr, uint16_t &finishE
|
||||
transmitMessage(msg);
|
||||
}
|
||||
|
||||
static inline void interfaceTest()
|
||||
{
|
||||
constexpr auto onSignOn = []() {};
|
||||
constexpr auto onSetParam = []() {};
|
||||
constexpr auto onGetParam = [](stk500v2::Param param, uint8_t &result) {
|
||||
using stk500v2::Param;
|
||||
|
||||
switch (param) {
|
||||
case Param::HW_VER:
|
||||
result = 1;
|
||||
break;
|
||||
case Param::SW_MAJOR:
|
||||
result = 2;
|
||||
break;
|
||||
case Param::SW_MINOR:
|
||||
result = 10;
|
||||
break;
|
||||
case Param::SCK_DURATION:
|
||||
result = 2;
|
||||
break;
|
||||
case Param::VADJUST:
|
||||
result = 25;
|
||||
break;
|
||||
case Param::VTARGET:
|
||||
result = 49;
|
||||
break;
|
||||
case Param::OSC_PSCALE:
|
||||
result = 2;
|
||||
break;
|
||||
case Param::OSC_CMATCH:
|
||||
result = 127;
|
||||
break;
|
||||
case Param::TOPCARD_DETECT:
|
||||
result = 0xFF;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
constexpr auto callbacks = stk500v2::Callbacks<onSignOn, onSetParam, onGetParam>();
|
||||
|
||||
stk500v2::Stk500v2<uart_interface, TIMEOUT, callbacks> stk500;
|
||||
stk500.init();
|
||||
|
||||
while (stk500.callback())
|
||||
;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
/*interfaceTest();
|
||||
return 0;*/
|
||||
|
||||
serial.init();
|
||||
|
||||
Message msg;
|
||||
|
||||
Reference in New Issue
Block a user