Newer
Older
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#define M_PI ((float)3.141592654)
#define NB_LEDS_PER_STRIP 40
#define NB_LINES 1
#define NB_COLUMNS NB_LEDS_PER_STRIP
#define NB_PIXELS (NB_LINES*NB_COLUMNS)
#define RAW_SIZE (NB_PIXELS*3)
#define ONE_LINE_RAW_SIZE (NB_COLUMNS*3)
extern uint32_t gSecondCounter;
float getTime(void);
void setOffsetX(float X);
float updateOffsetX(float time);
void setSpeedRPS(float RPS, float time);
void waitBlocking(uint16_t x_us);
void setPC13asInput(void);
void setPC13asOutput(void);
uint8_t blueButtonIsDepressed(void);
void myWait1ms(int dtms);
void crash(uint8_t crash_code);
// Crash Codes
#define CC_CODE_SINCOS 0x01
#define CC_UNKNOWN_HAL_STATUS_CODE 0x02
#define CC_TO_MANY_COMMANDS 0x03
#define CC_SW_ERROR_CMD_MNGR 0x04
#define CC_UNMANAGED_WF_SP_STATE 0x05
#define CC_SW_ERROR_ROLLOVER 0x06
#define CC_MUST_INCREASE_PARSER_BUFFER_SIZE 0x07
#define CC_DMA_TIM2_CH1_FAILED 0x08
//#define CC_DMA_TIM8_CH3_FAILED 0x09
#define CC_MEMMANAGE_FAULT 0x0A
#define CC_BUS_FAULT 0x0B
#define CC_USAGE_FAULT 0x0C
#define CC_WIFI_STARTUP_FAILED 0x0D
#define CC_SERIAL_OVERFLOW_TX_WIFI 0x0E
#define CC_SERIAL_OVERFLOW_TX_PC 0x0F
#define CC_MAIN_POWER_UP_FAILED 0x10
#define CC_DAC1_CONV1_FAILED 0x11
#define CC_DAC1_CONV2_FAILED 0x12
#define CC_HARD_FAULT 0xFF
#define RunLedOn() HAL_GPIO_WritePin(LD3_GPIO_Port,LD3_Pin,GPIO_PIN_SET)
#define RunLedOff() HAL_GPIO_WritePin(LD3_GPIO_Port,LD3_Pin,GPIO_PIN_RESET)
#define RunLedToggle() HAL_GPIO_TogglePin(LD3_GPIO_Port,LD3_Pin)
typedef uint8_t bool;
#define true 1
#define false 0
// TIM3 pour la capture
// TIM6 pour la gnration
// clocks @ 64Mhz
// prescaler (3+1=4) => 16 Mhz ==> rollover in 4ms > 2ms OK.
// Starting from a set of 8 pulse width from 1ms to 2ms with X bits precision.
// Generate 8 pulses on 8 GPIOs
#define NB_SERVOS 8
#define SEGMENT_LENGTH 90
#define SPINE_SIZE (SEGMENT_LENGTH*(NB_SERVOS-1))
#define TIMER_FREQUENCY (1.0e6f)
#define T1_0 ((uint16_t) (1.0e-3f*TIMER_FREQUENCY))
#define T1_5 ((uint16_t) (1.5e-3f*TIMER_FREQUENCY))
#define T2_0 ((uint16_t) (2.0e-3f*TIMER_FREQUENCY))
#define T3_0 ((uint16_t) (3.0e-3f*TIMER_FREQUENCY))
void clig(void);
void cligFast(void);
uint16_t clamp(uint16_t x, uint16_t min, uint16_t max);
float linear(float x, int x1, int x2, int y1, int y2);