forked from R0b0shack/VESC-UART-Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvesc_uart.h
66 lines (49 loc) · 2.25 KB
/
vesc_uart.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// Created by Daniel Claes on 01/05/2016.
//
#ifndef VESC_UART_H
#define VESC_UART_H
#include "config.h"
//#ifndef _CONFIG_h
/*
Copyright 2015 - 2017 Andreas Chaitidis [email protected]
This program is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
/*TThis library was created on an Adruinio 2560 with different serial ports to have a better possibility
to debug. The serial ports are define with #define:
#define SERIALIO Serial1 for the UART port to VESC
#define DEBUGSERIAL Serial for debuging over USB
So you need here to define the right serial port for your arduino.
If you want to use debug, uncomment DEBUGSERIAL and define a port.*/
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "datatypes.h"
bool unpack_payload(uint8_t *message, int lenMes, uint8_t *payload, int lenPa);
bool process_read_package(uint8_t *message, mc_values &values, int len);
///PackSendPayload Packs the payload and sends it over Serial.
///Define in a Config.h a SERIAL with the Serial in Arduino Style you want to you
///@param: payload as the payload [unit8_t Array] with length of int lenPayload
///@return the number of bytes send
int send_payload(uint8_t* payload, int lenPay);
///Sends a command to VESC and stores the returned data
///@param bldcMeasure struct with received data
//@return true if sucess
bool vesc_get_values(struct mc_values &values);
///ReceiveUartMessage receives the a message over Serial
///Define in a Config.h a SERIAL with the Serial in Arduino Style you want to you
///@parm the payload as the payload [unit8_t Array]
///@return the number of bytes receeived within the payload
int process_received_msg(uint8_t* payloadReceived);
#endif //VESC_UART_H