Skip to content

Commit 123bb00

Browse files
committed
Major 2019 update
1 parent 43c3bba commit 123bb00

File tree

134 files changed

+11866
-1599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+11866
-1599
lines changed

CHANGELOG

+65
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,68 @@
1+
=== FW 3.48 ===
2+
* Added pairing flag to appconf.
3+
* Decreased CAN TX timeout.
4+
5+
=== FW 3.47 ===
6+
* Current percentage limits.
7+
* Mcconf_temp based on current scale instead of absolute current.
8+
* Removed battery current from mcconf_temp.
9+
* Added current scale parameter.
10+
* Different braking behavior: prefer cogging over locking the brakes.
11+
12+
=== FW 3.46 ===
13+
* DC motor RPM measurement and RPM control when using encoder.
14+
* Support for configurable current low pass filter.
15+
* Much better recovery when failing to decode packets.
16+
* Run all detect functions in separate thread.
17+
* Fixed bug introduced when adding support for dual UARTs.
18+
* Added support for reverse state on NRF remote.
19+
* Support to disable app output for a specified time.
20+
21+
=== FW 3.45 ===
22+
* Default CAN ID from UUID, and hook to define it in hwconf.
23+
* CAN ping support.
24+
* Simultaneous firmware update over CAN-bus.
25+
* Fully automated motor detection, based on maximum motor power losses.
26+
* Sensor autodetection and configuration support.
27+
* Softer encoder detection.
28+
* Better NRF_EXT support.
29+
* New more reliable flux linkage measurement.
30+
* Simpler to add hardware versions to build system.
31+
* More DAS hardware support.
32+
* DRV8323s support.
33+
* Initial UAVCAN support.
34+
* Moved from uart to serial driver to avoid DMA conflicts.
35+
* Support for permanent UART.
36+
37+
=== FW 3.44 ===
38+
* NRF_EXT commands support.
39+
- Use NRF51822 with ESB remotes.
40+
* Different radio channel for NRF pairing.
41+
42+
=== FW 3.43 ===
43+
* Added battery ah to setup info.
44+
* Changed tacho values in COMM_GET_VALUES_SETUP to meters.
45+
* Added battery wh COMM_GET_VALUES_SETUP.
46+
* Better remaining battery capacity calculation.
47+
48+
=== FW 3.42 ===
49+
* Added setup info parameters:
50+
- Motor Poles
51+
- Gear Ratio
52+
- Wheel Diameter
53+
- Battery Type
54+
- Battery Cells
55+
* Added more CAN status messages.
56+
* Updated speed PID to start properly when braking is disabled.
57+
* Added COMM_GET_VALUES_SETUP.
58+
* Added COMM_SET_MCCONF_TEMP.
59+
* Added COMM_SET_MCCONF_TEMP_SETUP.
60+
* Added COMM_GET_VALUES_SELECTIVE.
61+
* Added COMM_GET_VALUES_SETUP_SELECTIVE.
62+
63+
=== FW 3.41 ===
64+
* First general purpose DC output implementation.
65+
166
=== FW 3.40 ===
267
* Added motor controller ID to COMM_GET_VALUES.
368

CONTRIBUTING

+20-2
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,36 @@ and
7171

7272
* If you write function comments, write them Doxygen-style.
7373

74-
* There is no limit on line length, so long lines in general should not be wrapped.
74+
* Line lengths should be kept below 90 characters if possible, but that is not a strict requirement if braking the line looks ugly.
75+
76+
* Source files should end with a new line.
77+
78+
* Avoid more than one conscutive empty line.
79+
7580

7681
=== Make sure that all hardware versions and configuration variations work ===
7782

7883
When making updates it is easy to break things for different configurations. In order to make sure that the firmware at least builds for different hardwares and configurations it is a good idea to run the build_all/rebuild_all script and ensure that is finished without warnings and/or errors.
7984

8085

86+
=== Other guidelines ===
87+
88+
* Use single precition floating point operations, as the FPU in the STM32F4 is 32 bits only. Double precision operations can take up to 50 times (!) longer.
89+
- float instead if double
90+
- Use the math library functions ending with f (sinf, cosf, powf, fabsf etc.)
91+
92+
* Make sure that the code compiles without warnings.
93+
94+
* Avoid dynamic memory allocation if possible, so that the RAM usage is known at compile time.
95+
96+
* If the code crashed randomly, use the ChibiOS state checker:
97+
http://www.chibios.org/dokuwiki/doku.php?id=chibios:articles:state_checker
98+
99+
81100
=== Be patient, and don't take criticism personally ===
82101

83102
Be prepared to have to rework your contribution several times before it is considered acceptable. Once code is in, it's difficult to get it reworked for better quality, so it's important that this is done before the code is even accepted. Don't take it personally; instead appreciate that it is this peer review that makes the code great in the end!
84103

85104

86105

87106
Thanks for reading!
88-

ChibiOS_3.0.2/os/hal/src/usb.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) {
757757
usbp->ep0state = USB_EP0_WAITING_TX0;
758758
return;
759759
}
760+
/* Falls through. */
760761
/* Falls into, it is intentional.*/
761762
case USB_EP0_WAITING_TX0:
762763
/* Transmit phase over, receiving the zero sized status packet.*/
@@ -782,7 +783,8 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) {
782783
case USB_EP0_RX:
783784
/* All the above are invalid states in the IN phase.*/
784785
osalDbgAssert(false, "EP0 state machine error");
785-
/* Falling through is intentional.*/
786+
/* Falls through. */
787+
/* Falling into is intentional.*/
786788
case USB_EP0_ERROR:
787789
/* Error response, the state machine goes into an error state, the low
788790
level layer will have to reset it to USB_EP0_WAITING_SETUP after
@@ -842,7 +844,8 @@ void _usb_ep0out(USBDriver *usbp, usbep_t ep) {
842844
case USB_EP0_SENDING_STS:
843845
/* All the above are invalid states in the IN phase.*/
844846
osalDbgAssert(false, "EP0 state machine error");
845-
/* Falling through is intentional.*/
847+
/* Falls through. */
848+
/* Falling into is intentional.*/
846849
case USB_EP0_ERROR:
847850
/* Error response, the state machine goes into an error state, the low
848851
level layer will have to reset it to USB_EP0_WAITING_SETUP after

ChibiOS_3.0.2/os/rt/src/chschd.c

+2
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,11 @@ static void wakeup(void *p) {
288288
#if CH_CFG_USE_SEMAPHORES == TRUE
289289
case CH_STATE_WTSEM:
290290
chSemFastSignalI(tp->p_u.wtsemp);
291+
/* Falls through. */
291292
/* Falls into, intentional. */
292293
#endif
293294
#if (CH_CFG_USE_CONDVARS == TRUE) && (CH_CFG_USE_CONDVARS_TIMEOUT == TRUE)
295+
/* Falls through. */
294296
case CH_STATE_WTCOND:
295297
#endif
296298
case CH_STATE_QUEUED:

Makefile

+6-2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
107107
include hwconf/hwconf.mk
108108
include applications/applications.mk
109109
include nrf/nrf.mk
110+
include libcanard/canard.mk
110111

111112
# Define linker script file here
112113
LDSCRIPT= ld_eeprom_emu.ld
@@ -147,9 +148,11 @@ CSRC = $(STARTUPSRC) \
147148
flash_helper.c \
148149
mc_interface.c \
149150
mcpwm_foc.c \
151+
gpdrive.c \
150152
$(HWSRC) \
151153
$(APPSRC) \
152-
$(NRFSRC)
154+
$(NRFSRC) \
155+
$(CANARDSRC)
153156

154157
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
155158
# setting.
@@ -186,7 +189,8 @@ INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
186189
appconf \
187190
$(HWINC) \
188191
$(APPINC) \
189-
$(NRFINC)
192+
$(NRFINC) \
193+
$(CANARDINC)
190194

191195
#
192196
# Project, sources and paths

appconf/appconf_default.h

+16-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
// Default app configuration
2424
#ifndef APPCONF_CONTROLLER_ID
25-
#define APPCONF_CONTROLLER_ID 0
25+
#define APPCONF_CONTROLLER_ID -1 // Controller id. -1 means it should be calculated from UUID.
2626
#endif
2727
#ifndef APPCONF_TIMEOUT_MSEC
2828
#define APPCONF_TIMEOUT_MSEC 1000
@@ -31,14 +31,23 @@
3131
#define APPCONF_TIMEOUT_BRAKE_CURRENT 0.0
3232
#endif
3333
#ifndef APPCONF_SEND_CAN_STATUS
34-
#define APPCONF_SEND_CAN_STATUS false
34+
#define APPCONF_SEND_CAN_STATUS CAN_STATUS_DISABLED
35+
#endif
36+
#ifndef APPCONF_UAVCAN_ENABLE
37+
#define APPCONF_UAVCAN_ENABLE false
38+
#endif
39+
#ifndef APPCONF_UAVCAN_ESC_INDEX
40+
#define APPCONF_UAVCAN_ESC_INDEX 0
3541
#endif
3642
#ifndef APPCONF_SEND_CAN_STATUS_RATE_HZ
37-
#define APPCONF_SEND_CAN_STATUS_RATE_HZ 100
43+
#define APPCONF_SEND_CAN_STATUS_RATE_HZ 50
3844
#endif
3945
#ifndef APPCONF_CAN_BAUD_RATE
4046
#define APPCONF_CAN_BAUD_RATE CAN_BAUD_500K
4147
#endif
48+
#ifndef APPCONF_PAIRING_DONE
49+
#define APPCONF_PAIRING_DONE false
50+
#endif
4251

4352
// The default app is UART in case the UART port is used for
4453
// firmware updates.
@@ -87,7 +96,7 @@
8796
#define APPCONF_PPM_RAMP_TIME_NEG 0.1
8897
#endif
8998
#ifndef APPCONF_PPM_MULTI_ESC
90-
#define APPCONF_PPM_MULTI_ESC false
99+
#define APPCONF_PPM_MULTI_ESC true
91100
#endif
92101
#ifndef APPCONF_PPM_TC
93102
#define APPCONF_PPM_TC false
@@ -116,7 +125,7 @@
116125
#define APPCONF_ADC_VOLTAGE2_START 0.9
117126
#endif
118127
#ifndef APPCONF_ADC_VOLTAGE2_END
119-
#define APPCONF_ADC_VOLTAGE2_END 3.0
128+
#define APPCONF_ADC_VOLTAGE2_END 3.0
120129
#endif
121130
#ifndef APPCONF_ADC_USE_FILTER
122131
#define APPCONF_ADC_USE_FILTER true
@@ -152,7 +161,7 @@
152161
#define APPCONF_ADC_RAMP_TIME_NEG 0.1
153162
#endif
154163
#ifndef APPCONF_ADC_MULTI_ESC
155-
#define APPCONF_ADC_MULTI_ESC false
164+
#define APPCONF_ADC_MULTI_ESC true
156165
#endif
157166
#ifndef APPCONF_ADC_TC
158167
#define APPCONF_ADC_TC false
@@ -195,7 +204,7 @@
195204
#define APPCONF_CHUK_THROTTLE_EXP_MODE THR_EXP_POLY
196205
#endif
197206
#ifndef APPCONF_CHUK_MULTI_ESC
198-
#define APPCONF_CHUK_MULTI_ESC false
207+
#define APPCONF_CHUK_MULTI_ESC true
199208
#endif
200209
#ifndef APPCONF_CHUK_TC
201210
#define APPCONF_CHUK_TC false

applications/app.c

+42-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 Benjamin Vedder [email protected]
2+
Copyright 2016 - 2019 Benjamin Vedder [email protected]
33
44
This file is part of the VESC firmware.
55
@@ -27,6 +27,12 @@
2727

2828
// Private variables
2929
static app_configuration appconf;
30+
static virtual_timer_t output_vt;
31+
static bool output_vt_init_done = false;
32+
static volatile bool output_disabled_now = false;
33+
34+
// Private functions
35+
static void output_vt_cb(void *arg);
3036

3137
const app_configuration* app_get_configuration(void) {
3238
return &appconf;
@@ -117,3 +123,38 @@ void app_set_configuration(app_configuration *conf) {
117123

118124
rfhelp_update_conf(&appconf.app_nrf_conf);
119125
}
126+
127+
/**
128+
* Disable output on apps
129+
*
130+
* @param time_ms
131+
* The amount of time to disable output in ms
132+
* 0: Enable output now
133+
* -1: Disable forever
134+
* >0: Amount of milliseconds to disable output
135+
*/
136+
void app_disable_output(int time_ms) {
137+
if (!output_vt_init_done) {
138+
chVTObjectInit(&output_vt);
139+
output_vt_init_done = true;
140+
}
141+
142+
if (time_ms == 0) {
143+
output_disabled_now = false;
144+
} else if (time_ms == -1) {
145+
output_disabled_now = true;
146+
chVTReset(&output_vt);
147+
} else {
148+
output_disabled_now = true;
149+
chVTSet(&output_vt, MS2ST(time_ms), output_vt_cb, 0);
150+
}
151+
}
152+
153+
bool app_is_output_disabled(void) {
154+
return output_disabled_now;
155+
}
156+
157+
static void output_vt_cb(void *arg) {
158+
(void)arg;
159+
output_disabled_now = false;
160+
}

applications/app.h

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
// Functions
2626
const app_configuration* app_get_configuration(void);
2727
void app_set_configuration(app_configuration *conf);
28+
void app_disable_output(int time_ms);
29+
bool app_is_output_disabled(void);
2830

2931
// Standard apps
3032
void app_ppm_start(void);
@@ -41,8 +43,10 @@ float app_adc_get_decoded_level2(void);
4143
float app_adc_get_voltage2(void);
4244

4345
void app_uartcomm_start(void);
46+
void app_uartcomm_start_permanent(void);
4447
void app_uartcomm_stop(void);
4548
void app_uartcomm_configure(uint32_t baudrate);
49+
void app_uartcomm_send_packet(unsigned char *data, unsigned int len);
4650

4751
void app_nunchuk_start(void);
4852
void app_nunchuk_stop(void);

applications/app_adc.c

+6
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ static THD_FUNCTION(adc_thread, arg) {
244244
}
245245
}
246246

247+
// All pins and buttons are still decoded for debugging, even
248+
// when output is disabled.
249+
if (app_is_output_disabled()) {
250+
continue;
251+
}
252+
247253
switch (config.ctrl_type) {
248254
case ADC_CTRL_TYPE_CURRENT_REV_CENTER:
249255
case ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_CENTER:

0 commit comments

Comments
 (0)