kopia lustrzana https://github.com/SP8EBC/ParaTNC
- Some files renamed
- Added callback and request for 0x26 routine - Added context structurepull/2/head
rodzic
299c0a8d6a
commit
f1e4a0003b
|
@ -198,7 +198,7 @@
|
|||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="Timer.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry excluding="src/drivers/tm_stm32fonewire/tm_stm32f1_onewire.c|src/stm32f1-stdperiph/stm32f10x_wwdg.c|src/stm32f1-stdperiph/stm32f10x_spi.c|src/stm32f1-stdperiph/stm32f10x_sdio.c|src/stm32f1-stdperiph/stm32f10x_rtc.c|src/stm32f1-stdperiph/stm32f10x_pwr.c|src/stm32f1-stdperiph/stm32f10x_fsmc.c|src/stm32f1-stdperiph/stm32f10x_flash.c|src/stm32f1-stdperiph/stm32f10x_dbgmcu.c|src/stm32f1-stdperiph/stm32f10x_dac.c|src/stm32f1-stdperiph/stm32f10x_crc.c|src/stm32f1-stdperiph/stm32f10x_cec.c|src/stm32f1-stdperiph/stm32f10x_can.c|src/stm32f1-stdperiph/stm32f10x_bkp.c|src/stm32f1-stdperiph/stm32f10x_adc.c" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="system"/>
|
||||
<entry excluding="src/stm32f1-stdperiph/stm32f10x_rtc.c|src/stm32f1-stdperiph/stm32f10x_dbgmcu.c|src/stm32f1-stdperiph/stm32f10x_adc.c|src/stm32f1-stdperiph/stm32f10x_wwdg.c|src/drivers/tm_stm32fonewire/tm_stm32f1_onewire.c|src/stm32f1-stdperiph/stm32f10x_bkp.c|src/stm32f1-stdperiph/stm32f10x_crc.c|src/stm32f1-stdperiph/stm32f10x_dac.c|src/stm32f1-stdperiph/stm32f10x_can.c|src/stm32f1-stdperiph/stm32f10x_spi.c|src/stm32f1-stdperiph/stm32f10x_pwr.c|src/stm32f1-stdperiph/stm32f10x_flash.c|src/stm32f1-stdperiph/stm32f10x_sdio.c|src/stm32f1-stdperiph/stm32f10x_fsmc.c|src/stm32f1-stdperiph/stm32f10x_cec.c" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="system"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
@ -357,7 +357,7 @@
|
|||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="Timer.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
<entry excluding="src/drivers/tm_stm32fonewire/tm_stm32f1_onewire.c|src/stm32f1-stdperiph/stm32f10x_wwdg.c|src/stm32f1-stdperiph/stm32f10x_tim.c|src/stm32f1-stdperiph/stm32f10x_spi.c|src/stm32f1-stdperiph/stm32f10x_sdio.c|src/stm32f1-stdperiph/stm32f10x_rtc.c|src/stm32f1-stdperiph/stm32f10x_pwr.c|src/stm32f1-stdperiph/stm32f10x_fsmc.c|src/stm32f1-stdperiph/stm32f10x_flash.c|src/stm32f1-stdperiph/stm32f10x_dbgmcu.c|src/stm32f1-stdperiph/stm32f10x_dac.c|src/stm32f1-stdperiph/stm32f10x_crc.c|src/stm32f1-stdperiph/stm32f10x_cec.c|src/stm32f1-stdperiph/stm32f10x_can.c|src/stm32f1-stdperiph/stm32f10x_bkp.c|src/stm32f1-stdperiph/stm32f10x_adc.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="system"/>
|
||||
<entry excluding="src/stm32f1-stdperiph/stm32f10x_rtc.c|src/stm32f1-stdperiph/stm32f10x_dbgmcu.c|src/stm32f1-stdperiph/stm32f10x_adc.c|src/stm32f1-stdperiph/stm32f10x_wwdg.c|src/stm32f1-stdperiph/stm32f10x_tim.c|src/drivers/tm_stm32fonewire/tm_stm32f1_onewire.c|src/stm32f1-stdperiph/stm32f10x_bkp.c|src/stm32f1-stdperiph/stm32f10x_crc.c|src/stm32f1-stdperiph/stm32f10x_dac.c|src/stm32f1-stdperiph/stm32f10x_can.c|src/stm32f1-stdperiph/stm32f10x_spi.c|src/stm32f1-stdperiph/stm32f10x_pwr.c|src/stm32f1-stdperiph/stm32f10x_flash.c|src/stm32f1-stdperiph/stm32f10x_sdio.c|src/stm32f1-stdperiph/stm32f10x_fsmc.c|src/stm32f1-stdperiph/stm32f10x_cec.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="system"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
|
|
@ -9,7 +9,7 @@ RM := rm -rf
|
|||
# All of the sources participating in the build are defined here
|
||||
-include sources.mk
|
||||
-include system/src/ve_direct_protocol/subdir.mk
|
||||
-include system/src/umb_client/subdir.mk
|
||||
-include system/src/umb_master/subdir.mk
|
||||
-include system/src/stm32f1-stdperiph/subdir.mk
|
||||
-include system/src/newlib/subdir.mk
|
||||
-include system/src/drivers/subdir.mk
|
||||
|
|
|
@ -35,6 +35,6 @@ system/src/diag \
|
|||
system/src/drivers \
|
||||
system/src/newlib \
|
||||
system/src/stm32f1-stdperiph \
|
||||
system/src/umb_client \
|
||||
system/src/umb_master \
|
||||
system/src/ve_direct_protocol \
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "drivers/_dht22.h"
|
||||
#include "drivers/dallas.h"
|
||||
#include "drivers/ms5611.h"
|
||||
#include "../umb_client/umb_client.h"
|
||||
#include "../umb_master/umb_master.h"
|
||||
|
||||
|
||||
#ifndef RTE_WX_H_
|
||||
|
@ -41,8 +41,11 @@ extern DallasQF rte_wx_current_dallas_qf, rte_wx_error_dallas_qf;
|
|||
extern DallasAverage_t rte_wx_dallas_average;
|
||||
extern ms5611_qf_t rte_wx_ms5611_qf;
|
||||
|
||||
#ifdef _UMB_CLIENT
|
||||
#ifdef _UMB_MASTER
|
||||
|
||||
extern umb_frame_t rte_wx_umb;
|
||||
extern uint8_t rte_wx_last_status;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
47
src/main.c
47
src/main.c
|
@ -32,9 +32,6 @@
|
|||
#include "rte_pv.h"
|
||||
#include "rte_main.h"
|
||||
|
||||
//#include "Timer.h"
|
||||
//#include "BlinkLed.h"
|
||||
|
||||
#ifdef _METEO
|
||||
#include <wx_handler.h>
|
||||
#include "drivers/dallas.h"
|
||||
|
@ -51,6 +48,8 @@
|
|||
|
||||
#include "KissCommunication.h"
|
||||
|
||||
#define SOH 0x01
|
||||
|
||||
//#define SERIAL_TX_TEST_MODE
|
||||
|
||||
// Niebieska dioda -> DCD
|
||||
|
@ -109,6 +108,11 @@ uint16_t buffer_len = 0;
|
|||
#ifdef _VICTRON
|
||||
#endif
|
||||
|
||||
#ifdef _UMB_MASTER
|
||||
// return value from UMB related functions
|
||||
umb_retval_t main_umb_retval = UMB_UNINITIALIZED;
|
||||
#endif
|
||||
|
||||
char after_tx_lock;
|
||||
|
||||
unsigned short rx10m = 0, tx10m = 0, digi10m = 0, kiss10m = 0;
|
||||
|
@ -220,6 +224,15 @@ main(int argc, char* argv[])
|
|||
dallas_init(GPIOC, GPIO_Pin_11, GPIO_PinSource11, &rte_wx_dallas_average);
|
||||
#endif
|
||||
|
||||
#if defined(_UMB_MASTER)
|
||||
// UMB client cannot be used in the same time with TX20 or analogue anemometer
|
||||
#undef _ANEMOMETER_TX20
|
||||
#undef _ANEMOMETER_ANALOGUE
|
||||
|
||||
// client initialization
|
||||
umb_master_init();
|
||||
#endif
|
||||
|
||||
#ifdef _ANEMOMETER_TX20
|
||||
TX20Init();
|
||||
#endif
|
||||
|
@ -300,7 +313,7 @@ main(int argc, char* argv[])
|
|||
// getting all meteo measuremenets to be sure that WX frames want be sent with zeros
|
||||
wx_get_all_measurements();
|
||||
|
||||
#ifdef _VICTRON
|
||||
#if defined _VICTRON && !defined _UMB_MASTER
|
||||
// initializing protocol parser
|
||||
ve_direct_parser_init(&rte_pv_struct, &rte_pv_average);
|
||||
|
||||
|
@ -311,7 +324,13 @@ main(int argc, char* argv[])
|
|||
|
||||
// switching UART to receive mode to be ready for data from charging controller
|
||||
srl_receive_data(VE_DIRECT_MAX_FRAME_LN, 0x0D, 0, 0, 0, 0);
|
||||
#else
|
||||
|
||||
#elif !defined _VICTRON && defined _UMB_MASTER
|
||||
|
||||
srl_receive_data(8, SOH, 0x00, 0, 6, 12);
|
||||
|
||||
|
||||
#elif ! defined _VICTRON && !defined _UMB_MASTER
|
||||
// switching UART to receive mode to be ready for KISS frames from host
|
||||
srl_receive_data(100, FEND, FEND, 0, 0, 0);
|
||||
#endif
|
||||
|
@ -376,7 +395,7 @@ main(int argc, char* argv[])
|
|||
rx10m++;
|
||||
}
|
||||
|
||||
#ifdef _VICTRON
|
||||
#if defined _VICTRON
|
||||
// if new KISS message has been received from the host
|
||||
if (srl_rx_state == SRL_RX_DONE || srl_rx_state == SRL_RX_ERROR) {
|
||||
|
||||
|
@ -403,6 +422,22 @@ main(int argc, char* argv[])
|
|||
|
||||
srl_receive_data(VE_DIRECT_MAX_FRAME_LN, 0x0D, 0, 0, 0, 0);
|
||||
}
|
||||
#elif defined _UMB_MASTER
|
||||
// if some UMB data have been received
|
||||
if (srl_rx_state == SRL_RX_DONE) {
|
||||
main_umb_retval = umb_parse_serial_buffer_to_frame(srl_get_rx_buffer(), srl_get_num_bytes_rxed(), &rte_wx_umb);
|
||||
|
||||
if (main_umb_retval != UMB_OK) {
|
||||
umb_master_callback(&rte_wx_umb);
|
||||
}
|
||||
|
||||
srl_receive_data(8, SOH, 0x00, 0, 6, 12);
|
||||
}
|
||||
|
||||
// if there were an error during receiving frame from host, restart rxing once again
|
||||
if (srl_rx_state == SRL_RX_ERROR) {
|
||||
srl_receive_data(8, SOH, 0x00, 0, 6, 12);
|
||||
}
|
||||
#else
|
||||
// if new KISS message has been received from the host
|
||||
if (srl_rx_state == SRL_RX_DONE) {
|
||||
|
|
|
@ -32,8 +32,9 @@ DallasQF rte_wx_current_dallas_qf, rte_wx_error_dallas_qf = DALLAS_QF_UNKNOWN;
|
|||
DallasAverage_t rte_wx_dallas_average;
|
||||
ms5611_qf_t rte_wx_ms5611_qf;
|
||||
|
||||
#ifdef _UMB_CLIENT
|
||||
#ifdef _UMB_MASTER
|
||||
umb_frame_t rte_wx_umb;
|
||||
uint8_t rte_wx_last_status = 0;
|
||||
#endif
|
||||
|
||||
void rte_wx_init(void) {
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* umb_0x26_status_request.h
|
||||
*
|
||||
* Created on: 23.02.2020
|
||||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_UMB_MASTER_UMB_0X26_STATUS_H_
|
||||
#define INCLUDE_UMB_MASTER_UMB_0X26_STATUS_H_
|
||||
|
||||
#include "../umb_master/umb_retval_t.h"
|
||||
|
||||
umb_retval_t umb_0x26_status_request();
|
||||
umb_retval_t umb_0x26_status_callback();
|
||||
|
||||
#endif /* INCLUDE_UMB_MASTER_UMB_0X26_STATUS_H_ */
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* umb_context_t.h
|
||||
*
|
||||
* Created on: 23.02.2020
|
||||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_UMB_MASTER_UMB_CONTEXT_T_H_
|
||||
#define INCLUDE_UMB_MASTER_UMB_CONTEXT_T_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "umb_state_t.h"
|
||||
|
||||
typedef struct umb_context_t {
|
||||
|
||||
int16_t current_routine;
|
||||
|
||||
umb_state_t state;
|
||||
|
||||
} umb_context_t;
|
||||
|
||||
#endif /* INCLUDE_UMB_MASTER_UMB_CONTEXT_T_H_ */
|
|
@ -5,8 +5,8 @@
|
|||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_UMB_CLIENT_UMB_FRAME_T_H_
|
||||
#define INCLUDE_UMB_CLIENT_UMB_FRAME_T_H_
|
||||
#ifndef INCLUDE_UMB_MASTER_UMB_FRAME_T_H_
|
||||
#define INCLUDE_UMB_MASTER_UMB_FRAME_T_H_
|
||||
|
||||
#define UMB_FRAME_MAX_PAYLOAD_LN 40
|
||||
|
||||
|
@ -26,10 +26,10 @@ typedef struct umb_frame_t {
|
|||
|
||||
uint8_t payload[UMB_FRAME_MAX_PAYLOAD_LN];
|
||||
|
||||
uint8_t checksum_lsb;
|
||||
uint8_t calculated_checksum_lsb;
|
||||
|
||||
uint8_t checksum_msb;
|
||||
uint8_t calculated_checksum_msb;
|
||||
|
||||
} umb_frame_t;
|
||||
|
||||
#endif /* INCLUDE_UMB_CLIENT_UMB_FRAME_T_H_ */
|
||||
#endif /* INCLUDE_UMB_MASTER_UMB_FRAME_T_H_ */
|
|
@ -5,20 +5,24 @@
|
|||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_UMB_CLIENT_UMB_CLIENT_H_
|
||||
#define INCLUDE_UMB_CLIENT_UMB_CLIENT_H_
|
||||
#ifndef INCLUDE_UMB_MASTER_UMB_MASTER_H_
|
||||
#define INCLUDE_UMB_MASTER_UMB_MASTER_H_
|
||||
|
||||
#include <umb_master/umb_frame_t.h>
|
||||
#include <umb_master/umb_retval_t.h>
|
||||
#include <umb_master/umb_context_t.h>
|
||||
#include "station_config.h"
|
||||
#include "umb_frame_t.h"
|
||||
#include "umb_retval_t.h"
|
||||
|
||||
#ifdef _UMB_CLIENT
|
||||
#ifdef _UMB_MASTER
|
||||
|
||||
void umb_client_init();
|
||||
extern umb_context_t umb_context;
|
||||
|
||||
void umb_master_init();
|
||||
umb_retval_t umb_parse_serial_buffer_to_frame(uint8_t* serial_buffer, uint16_t buffer_ln, umb_frame_t* frame);
|
||||
umb_retval_t umb_parse_frame_to_serial_buffer(uint8_t* serial_buffer, uint16_t buffer_ln, umb_frame_t* frame);
|
||||
uint16_t umb_calc_crc(uint16_t crc_buff, uint8_t input);
|
||||
umb_retval_t umb_master_callback(umb_frame_t* frame);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* INCLUDE_UMB_CLIENT_UMB_CLIENT_H_ */
|
||||
#endif /* INCLUDE_UMB_MASTER_UMB_MASTER_H_ */
|
|
@ -5,15 +5,19 @@
|
|||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_UMB_CLIENT_UMB_RETVAL_T_H_
|
||||
#define INCLUDE_UMB_CLIENT_UMB_RETVAL_T_H_
|
||||
#ifndef INCLUDE_UMB_MASTER_UMB_RETVAL_T_H_
|
||||
#define INCLUDE_UMB_MASTER_UMB_RETVAL_T_H_
|
||||
|
||||
typedef enum umb_retval_t {
|
||||
UMB_UNINITIALIZED = 127,
|
||||
UMB_OK = 0,
|
||||
UMB_FRAME_TOO_LONG_FOR_TX = -1,
|
||||
UMB_NOT_VALID_FRAME = -2,
|
||||
UMB_TO_ANOTHER_MASTER = -3,
|
||||
UMB_RECV_FRAME_TOO_LONG = -4,
|
||||
UMB_WRONG_CRC = -5
|
||||
UMB_WRONG_CRC = -5,
|
||||
UMB_BUSY = -6,
|
||||
UMB_GENERAL_ERROR = -63
|
||||
}umb_retval_t;
|
||||
|
||||
#endif /* INCLUDE_UMB_CLIENT_UMB_RETVAL_T_H_ */
|
||||
#endif /* INCLUDE_UMB_MASTER_UMB_RETVAL_T_H_ */
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* umb_state_t.h
|
||||
*
|
||||
* Created on: 23.02.2020
|
||||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_UMB_MASTER_UMB_STATE_T_H_
|
||||
#define INCLUDE_UMB_MASTER_UMB_STATE_T_H_
|
||||
|
||||
typedef enum umb_state_t {
|
||||
UMB_STATUS_IDLE,
|
||||
UMB_STATUS_SENDING_REQUEST_TO_SLAVE,
|
||||
UMB_STATUS_WAITING_FOR_RESPONSE,
|
||||
UMB_STATUS_RESPONSE_AVALIABLE,
|
||||
UMB_STATUS_ERROR
|
||||
} umb_state_t;
|
||||
|
||||
#endif /* INCLUDE_UMB_MASTER_UMB_STATE_T_H_ */
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* umb_status_request.c
|
||||
*
|
||||
* Created on: 23.02.2020
|
||||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#include "../umb_master/umb_master.h"
|
||||
|
||||
#include "station_config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <umb_master/umb_0x26_status.h>
|
||||
|
||||
umb_retval_t umb_0x26_status_request(umb_frame_t* frame) {
|
||||
|
||||
if (umb_context.state != UMB_STATUS_IDLE && umb_context.state != UMB_STATUS_ERROR) {
|
||||
return UMB_BUSY;
|
||||
}
|
||||
|
||||
frame->command_id = 0x26;
|
||||
frame->slave_class = _UMB_SLAVE_CLASS;
|
||||
frame->slave_id = _UMB_SLAVE_ID;
|
||||
frame->lenght = 0;
|
||||
|
||||
memset(frame->payload, 0x00, UMB_FRAME_MAX_PAYLOAD_LN);
|
||||
|
||||
umb_context.state = UMB_STATUS_SENDING_REQUEST_TO_SLAVE;
|
||||
|
||||
return UMB_OK;
|
||||
|
||||
}
|
||||
|
||||
umb_retval_t umb_0x26_status_callback(umb_frame_t* frame) {
|
||||
|
||||
|
||||
umb_context.state = UMB_STATUS_IDLE;
|
||||
|
||||
return UMB_OK;
|
||||
}
|
|
@ -5,11 +5,11 @@
|
|||
* Author: mateusz
|
||||
*/
|
||||
|
||||
#include "../umb_client/umb_client.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <umb_master/umb_0x26_status.h>
|
||||
#include <umb_master/umb_master.h>
|
||||
|
||||
#ifdef _UMB_CLIENT
|
||||
#ifdef _UMB_MASTER
|
||||
|
||||
#define SOH 0x01
|
||||
#define STX 0x02
|
||||
|
@ -21,8 +21,11 @@
|
|||
#define MASTER_ID 0x01
|
||||
#define MASTER_CLASS 0xF0
|
||||
|
||||
void umb_client_init() {
|
||||
umb_context_t umb_context;
|
||||
|
||||
void umb_master_init() {
|
||||
umb_context.current_routine = -1;
|
||||
umb_context.state = UMB_STATUS_IDLE;
|
||||
}
|
||||
|
||||
umb_retval_t umb_parse_serial_buffer_to_frame(uint8_t* serial_buffer, uint16_t buffer_ln, umb_frame_t* frame) {
|
||||
|
@ -38,7 +41,7 @@ umb_retval_t umb_parse_serial_buffer_to_frame(uint8_t* serial_buffer, uint16_t b
|
|||
|
||||
frame->slave_class = serial_buffer[4];
|
||||
frame->slave_id = serial_buffer[5];
|
||||
frame->lenght = serial_buffer[6];
|
||||
frame->lenght = serial_buffer[6] - 2;
|
||||
|
||||
if (serial_buffer[8] != STX)
|
||||
return UMB_NOT_VALID_FRAME;
|
||||
|
@ -51,7 +54,7 @@ umb_retval_t umb_parse_serial_buffer_to_frame(uint8_t* serial_buffer, uint16_t b
|
|||
return UMB_RECV_FRAME_TOO_LONG;
|
||||
|
||||
// Copying payload of the frame from a serial buffer
|
||||
for (int i = 0; i < frame->lenght - 2; i++) {
|
||||
for (int i = 0; (i < frame->lenght && i < buffer_ln); i++) {
|
||||
frame->payload[i] = serial_buffer[10 + i];
|
||||
}
|
||||
|
||||
|
@ -59,18 +62,18 @@ umb_retval_t umb_parse_serial_buffer_to_frame(uint8_t* serial_buffer, uint16_t b
|
|||
crc_from_frame = serial_buffer[frame->lenght + 9] | (serial_buffer[frame->lenght + 10] << 8);
|
||||
|
||||
// recalculating crc from frame content
|
||||
for (int j = 0; j < frame->lenght + 8; j++) {
|
||||
for (int j = 0; j < frame->lenght + 8 + 2; j++) {
|
||||
crc = umb_calc_crc(crc, serial_buffer[j]);
|
||||
}
|
||||
|
||||
frame->checksum_lsb = crc & 0xFF;
|
||||
frame->checksum_msb = (crc & 0xFF00) >> 8;
|
||||
frame->calculated_checksum_lsb = crc & 0xFF;
|
||||
frame->calculated_checksum_msb = (crc & 0xFF00) >> 8;
|
||||
|
||||
if ( serial_buffer[frame->lenght + 9] != frame->checksum_lsb ||
|
||||
serial_buffer[frame->lenght + 10] != frame->checksum_msb)
|
||||
if ( serial_buffer[frame->lenght + 9 + 2] != frame->calculated_checksum_lsb ||
|
||||
serial_buffer[frame->lenght + 10 + 2] != frame->calculated_checksum_msb)
|
||||
return UMB_WRONG_CRC;
|
||||
|
||||
return 0;
|
||||
return UMB_OK;
|
||||
}
|
||||
|
||||
umb_retval_t umb_parse_frame_to_serial_buffer(uint8_t* serial_buffer, uint16_t buffer_ln, umb_frame_t* frame) {
|
||||
|
@ -89,12 +92,12 @@ umb_retval_t umb_parse_frame_to_serial_buffer(uint8_t* serial_buffer, uint16_t b
|
|||
serial_buffer[i++] = _UMB_SLAVE_CLASS;
|
||||
serial_buffer[i++] = MASTER_ID;
|
||||
serial_buffer[i++] = MASTER_CLASS;
|
||||
serial_buffer[i++] = frame->lenght;
|
||||
serial_buffer[i++] = frame->lenght + 2;
|
||||
serial_buffer[i++] = STX;
|
||||
serial_buffer[i++] = frame->command_id;
|
||||
serial_buffer[i++] = V10;
|
||||
|
||||
for (int j = 0; j < frame->lenght - 2; j++) {
|
||||
for (int j = 0; j < frame->lenght; j++) {
|
||||
serial_buffer[i++] = frame->payload[j];
|
||||
}
|
||||
|
||||
|
@ -108,7 +111,7 @@ umb_retval_t umb_parse_frame_to_serial_buffer(uint8_t* serial_buffer, uint16_t b
|
|||
serial_buffer[i++] = (uint8_t) (crc & 0xFF00) >> 8;
|
||||
serial_buffer[i++] = EOT;
|
||||
|
||||
return 0;
|
||||
return UMB_OK;
|
||||
}
|
||||
|
||||
uint16_t umb_calc_crc(uint16_t crc_buff, uint8_t input) {
|
||||
|
@ -131,4 +134,20 @@ uint16_t umb_calc_crc(uint16_t crc_buff, uint8_t input) {
|
|||
return (crc_buff);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called globally after receiving
|
||||
*/
|
||||
umb_retval_t umb_master_callback(umb_frame_t* frame) {
|
||||
|
||||
// looking for a callback to this response
|
||||
switch (frame->command_id) {
|
||||
case 0x26: {
|
||||
umb_0x26_status_callback(frame);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return UMB_OK;
|
||||
}
|
||||
|
||||
#endif
|
Ładowanie…
Reference in New Issue