Browse Source

update

master
zhaohe 2 years ago
parent
commit
51f61f7608
  1. 18
      app/MDK-ARM/app.uvguix.h_zha
  2. 2
      dep/libiflytop_micro
  3. 26
      src/board/hardware.cpp
  4. 10
      src/umain.cpp

18
app/MDK-ARM/app.uvguix.h_zha
File diff suppressed because it is too large
View File

2
dep/libiflytop_micro

@ -1 +1 @@
Subproject commit ffc78e8dc163fe8baea44325f3aeaca9ee05c146
Subproject commit 353a1158b633a08a4cf1c47940c698c494b9e978

26
src/board/hardware.cpp

@ -3,7 +3,7 @@
#include "i2c.h"
using namespace iflytop;
#define TAG "hardware"
#define ENABLE_CAN 0
#define ENABLE_CAN 1
extern "C" {
int fputc(int ch, FILE *stream) {
uint8_t c = ch;
@ -42,7 +42,7 @@ void Hardware::hardwareinit() {
*******************************************************************************/
#if ENABLE_CAN
IflytopCanSlave::iflytop_can_slave_config_t *config = canSlaveService.createDefaultConfig(DEVICE_ID);
canSlaveService.initialize(m_os, config);
canSlaveService.initialize(this, config);
canSlaveService.activateRxIT();
canSlaveService.registerListener(this);
#endif
@ -65,7 +65,7 @@ void Hardware::hardwareinit() {
/*******************************************************************************
* *
*******************************************************************************/
#if 1
#if 0
tmc_init();
tmc_extern_clk_enable();
// 4361初始化
@ -137,7 +137,7 @@ void Hardware::periodicJob() {
#endif
do_debug_light_state();
#if ENABLE_CAN
// testCanSlaveTxAndRx();
testCanSlaveTxAndRx();
#endif
}
void Hardware::do_debug_light_state() {
@ -174,7 +174,8 @@ void Hardware::testCanSlaveTxAndRx() {
static uint8_t tx[8] = {1, 2, 3, 4, 5, 6, 7, 8};
if (hasPassedMS(lastcall) > 1000) {
lastcall = getTicket();
canSlaveService.translate(0x01, tx, 8, 2);
// canSlaveService.translate(0x01, tx, 8, 2);
canSlaveService.sendReport(1, 2, 3, 100);
if (canSlaveService.getLastTransmitStatus() == HAL_OK) {
ZLOGI(TAG, "send ok");
} else {
@ -190,12 +191,19 @@ void Hardware::testCanSlaveTxAndRx() {
m_canOnRxDataFlag = false;
static CAN_RxHeaderTypeDef packetHeader;
static uint8_t packetData[8];
while (canSlaveService.getRxMessage(&packetHeader, packetData)) {
// while (canSlaveService.getRxMessage(&packetHeader, packetData)) {
// ZLOGI(TAG, "rx packet:");
// ZLOGI(TAG, "\tid:%x len:%d", packetHeader.StdId, packetHeader.DLC);
// ZLOGI_HEX(TAG, packetData, packetHeader.DLC);
// }
static IflytopCanSlave::packet_t packet;
while (canSlaveService.getRxPacket(&packet)) {
ZLOGI(TAG, "rx packet:");
ZLOGI(TAG, "\tid:%x len:%d", packetHeader.StdId, packetHeader.DLC);
ZLOGI_HEX(TAG, packetData, packetHeader.DLC);
ZLOGI(TAG, "\ttype:%01x, targetId:%01x, sourceId:%02x, seq:%02x, regAdd:%02x, regValue:%04x", //
packet.type, packet.targetId, packet.sourceId, packet.seq, packet.regAdd, packet.regValue);
}
// canSlaveService.activateRxIT();
canSlaveService.activateRxIT();
}
}
void Hardware::TMC4361APort_setResetPinState(uint16_t channel, bool state) { tmc_nRESET_pin_set_state(channel, state); }

10
src/umain.cpp

@ -28,21 +28,15 @@ class Main {
bool canOnRxDataFlag;
Main() { canOnRxDataFlag = false; }
void initialize();
void main(int argc, char const *argv[]);
};
void Main::initialize() {
zsignal_init(zsignal_listener, ZARRAY_SIZE(zsignal_listener));
m_hardware.hardwareinit();
// canSlaveService = &m_hardware.canSlaveService;
}
void Main::main(int argc, char const *argv[]) {
sys_loggger_enable(true);
ZLOGI(TAG, "VERSION:%s", VERSION);
// port_peltier_set_pwm(0);
initialize();
zsignal_init(zsignal_listener, ZARRAY_SIZE(zsignal_listener));
m_hardware.hardwareinit();
while (true) {
m_hardware.periodicJob();
// m_hardware.testCanSlaveTxAndRx(canOnRxDataFlag);

Loading…
Cancel
Save