diff --git a/Inc/common_defines.h b/Inc/common_defines.h
index 1ae1d7e..e83242b 100644
--- a/Inc/common_defines.h
+++ b/Inc/common_defines.h
@@ -11,7 +11,7 @@
//#define DEBUG
-#define FIRMWARE_VERSION 0x1412 // v1.4.1b2
+#define FIRMWARE_VERSION 0x1413 // v1.4.1b3
#define USED_PINS_NUM 30 // constant for BluePill and BlackPill boards
#define MAX_AXIS_NUM 8 // max 8
#define MAX_BUTTONS_NUM 128 // power of 2, max 128
diff --git a/Inc/main.h b/Inc/main.h
index ef3ec1a..2499307 100644
--- a/Inc/main.h
+++ b/Inc/main.h
@@ -18,7 +18,7 @@
static const dev_config_t init_config =
{
- .firmware_version = 0x1412, // do not change
+ .firmware_version = 0x1413, // do not change
/*
Name of device in devices dispatcher
diff --git a/MDK-ARM/FreeJoy.bin b/MDK-ARM/FreeJoy.bin
index c0e827c..7974009 100644
Binary files a/MDK-ARM/FreeJoy.bin and b/MDK-ARM/FreeJoy.bin differ
diff --git a/MDK-ARM/FreeJoy.uvoptx b/MDK-ARM/FreeJoy.uvoptx
index 2896770..57da301 100644
--- a/MDK-ARM/FreeJoy.uvoptx
+++ b/MDK-ARM/FreeJoy.uvoptx
@@ -148,24 +148,7 @@
UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM))
-
-
- 0
- 0
- 90
- 1
- 134237344
- 0
- 0
- 0
- 0
- 0
- 1
- ..\Src\leds.c
-
- \\FreeJoy\../Src/leds.c\90
-
-
+
0
diff --git a/Src/analog.c b/Src/analog.c
index a469c85..037a230 100644
--- a/Src/analog.c
+++ b/Src/analog.c
@@ -48,6 +48,9 @@ analog_data_t deadband_buffer[MAX_AXIS_NUM][DEADBAND_BUF_SIZE];
buttons_state_t axes_buttons[MAX_AXIS_NUM][3];
+uint8_t adc_cnt = 0;
+uint8_t sensors_cnt = 0;
+
adc_channel_config_t channel_config[MAX_AXIS_NUM] =
{
{ADC_Channel_0, 0}, {ADC_Channel_1, 1},
@@ -389,9 +392,6 @@ analog_data_t ShapeFunc (axis_config_t * p_axis_cfg, analog_data_t value, uint8
*/
void AxesInit (dev_config_t * p_dev_config)
{
- uint8_t adc_cnt = 0;
- uint8_t sensors_cnt = 0;
-
ADC_InitTypeDef ADC_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
@@ -506,6 +506,8 @@ void AxesInit (dev_config_t * p_dev_config)
*/
void ADC_Conversion (void)
{
+ if (adc_cnt > 0)
+ {
DMA_SetCurrDataCounter(DMA1_Channel1, MAX_AXIS_NUM);
DMA_Cmd(DMA1_Channel1, ENABLE);
ADC_Cmd(ADC1, ENABLE);
@@ -517,6 +519,7 @@ void ADC_Conversion (void)
ADC_Cmd(ADC1, DISABLE);
DMA_Cmd(DMA1_Channel1, DISABLE);
+ }
}
/**
diff --git a/Src/periphery.c b/Src/periphery.c
index c6448e7..f641339 100644
--- a/Src/periphery.c
+++ b/Src/periphery.c
@@ -86,7 +86,7 @@ void Timers_Init(dev_config_t * p_dev_config)
RCC_GetClocksFreq(&RCC_Clocks);
- // Encoders and HID timer
+ // Encoders, Axes and HID timer
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
TIM_TimeBaseStructInit(&TIM_TimeBaseInitStructure);
@@ -100,12 +100,11 @@ void Timers_Init(dev_config_t * p_dev_config)
TIM_Cmd(TIM1, ENABLE);
- // Axes timer
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
-
+ // PWM timer
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
TIM_TimeBaseStructInit(&TIM_TimeBaseInitStructure);
TIM_TimeBaseInitStructure.TIM_Prescaler = RCC_Clocks.PCLK1_Frequency/100000 - 1;
- TIM_TimeBaseInitStructure.TIM_Period = 400 - 1; // 2ms
+ TIM_TimeBaseInitStructure.TIM_Period = 400 - 1; // 2ms, 500Hz
TIM_TimeBaseInitStructure.TIM_ClockDivision = 0;
TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseInitStructure);
diff --git a/Src/usb_endp.c b/Src/usb_endp.c
index 9e5c4fe..b402b85 100644
--- a/Src/usb_endp.c
+++ b/Src/usb_endp.c
@@ -79,7 +79,6 @@ void EP1_OUT_Callback(void)
// 2 second delay for joy report
joy_millis = GetTick() + 2000;
- //Timers_Pause(2000);
/* Read received data (2 bytes) */
USB_SIL_Read(EP1_OUT, hid_buf);