Skip to content

Commit 42e6ba1

Browse files
committed
Switch to "new" UART idle interrupt
1 parent a5b777b commit 42e6ba1

5 files changed

Lines changed: 300 additions & 381 deletions

File tree

Inc/display_kingmeter.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Library for King-Meter displays
33
4-
Copyright © 2015 Michael Fabry (Michael@Fabry.de)
4+
Copyright © 2015 Michael Fabry (Michael@Fabry.de)
55
66
This program is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2727
#include "config.h"
2828
#include "stdint.h"
2929

30-
#if (DISPLAY_TYPE & DISPLAY_TYPE_KINGMETER)
30+
#if (DISPLAY_TYPE & DISPLAY_TYPE_KINGMETER|| DISPLAY_TYPE & DISPLAY_TYPE_DEBUG)
3131

3232
// Definitions
3333
#define KM_MAX_WHEELTIME 0x0DAC // Maximum Wheeltime reported to the display (e.g. when wheel is stopped)
@@ -66,6 +66,8 @@ typedef struct
6666
// Parameters received from display in setting mode:
6767
uint16_t WheelSize_mm; // Unit: 1mm
6868
uint8_t PAS_RUN_Direction; // KM_PASDIR_FORWARD / KM_PASDIR_BACKWARD
69+
uint8_t ExecAutodetect; // 0 or 1, Use Parameter P18 of EN06 protocol
70+
uint8_t Reverse; // 0 or 1, Use Parameter P19 of EN06 protocol
6971
uint8_t PAS_SCN_Tolerance; // Number of PAS signals to start the motor
7072
uint8_t PAS_N_Ratio; // 0..255 PAS ratio
7173
uint8_t HND_HL_ThrParam; // KM_HND_HL_NO / KM_HND_HL_YES
@@ -113,8 +115,8 @@ typedef struct
113115
uint8_t Throttle; // KM_THROTTLE_OFF / KM_THROTTLE_ON
114116
uint8_t CruiseControl; // KM_CRUISE_OFF / KM_CRUISE_ON
115117
uint8_t OverSpeed; // KM_OVERSPEED_OFF / KM_OVERSPEED_ON
116-
uint16_t SPEEDMAX_Limit_x10; // Unit: 0.1km/h
117-
uint16_t CUR_Limit_x10; // Unit: 0.1A
118+
uint16_t SPEEDMAX_Limit; // Unit: km/h
119+
uint16_t CUR_Limit_mA; // Unit: mA
118120

119121
}RX_PARAM_t;
120122

@@ -123,6 +125,7 @@ typedef struct
123125
#define KM_ERROR_NONE 0x00
124126
#define KM_ERROR_COMM 0x30
125127
#define KM_ERROR_OVHT 0x25
128+
#define KM_ERROR_IOVHT 0x26
126129

127130
typedef struct
128131
{
@@ -140,16 +143,16 @@ typedef struct
140143
#endif
141144

142145

143-
#if (DISPLAY_TYPE == DISPLAY_TYPE_KINGMETER_901U)
144-
#define KM_MAX_RXBUFF 30
146+
#if (DISPLAY_TYPE == DISPLAY_TYPE_KINGMETER_901U|| DISPLAY_TYPE & DISPLAY_TYPE_DEBUG)
147+
#define KM_MAX_RXBUFF 64
145148
#define KM5S_NM_RXBUFF 15 // KM5S RX-Buffer length for normal mode
146149
#define KM_MAX_TXBUFF 13
147150
#endif
148151

149152
typedef struct
150153
{
151154
uint8_t RxState;
152-
uint32_t LastRx;
155+
int8_t DirectSetpoint;
153156

154157
uint8_t RxBuff[KM_MAX_RXBUFF];
155158
uint8_t RxCnt;
@@ -176,4 +179,3 @@ void KingMeter_Init (KINGMETER_t* KM_ctx);
176179
#endif // Display Type Kingmeter
177180

178181
#endif // KINGMETER_H
179-

Inc/main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ extern uint16_t switchtime[3];
119119
extern uint32_t ui32_tim1_counter;
120120
extern uint32_t uint32_PAS_counter;
121121
extern uint8_t throttle_is_set(void);
122+
extern void UART_IdleItCallback(void);
122123

123124
typedef struct
124125
{
@@ -156,6 +157,7 @@ typedef struct
156157
uint8_t assist_level;
157158
uint8_t regen_level;
158159
int16_t Temperature;
160+
int16_t int_Temperature;
159161
int8_t system_state;
160162
int8_t gear_state;
161163
int8_t error_state;

0 commit comments

Comments
 (0)