Skip to content

Commit 71e5631

Browse files
committedApr 25, 2024
The little update: 2.0rc4
1 parent 4daaae3 commit 71e5631

19 files changed

+244
-117
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
.vscode
12
build

‎docs/devices/FNIRSI GC-01/install.md

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Data logging can store up to 5060 data points. At normal radiation levels (20 cp
6363
The HV profile settings are:
6464

6565
* Factory default: 9.207 kHz frequency and 75 % duty cycle.
66+
* Accuracy: 5 kHz frequency and 2 % duty cycle.
6667
* Energy-saving: 5 kHz frequency and 1.5 % duty cycle.
6768

6869
### FNIRSI GC-01 with a APM32F103R8 (Geehy) processor
@@ -74,4 +75,5 @@ Data logging can store up to 63756 data points. At normal radiation levels (20 c
7475
The HV profile settings are:
7576

7677
* Factory default: 47.058 kHz frequency and 50 % duty cycle.
78+
* Accuracy: 5 kHz frequency and 2 % duty cycle.
7779
* Energy-saving: 5 kHz frequency and 1.5 % duty cycle.

‎platform.io/lib/stm32/stm32-ext.h

+14-15
Original file line numberDiff line numberDiff line change
@@ -1187,11 +1187,6 @@ __STATIC_INLINE void rtc_set_date_time(uint32_t dr,
11871187
RTC->DR = dr;
11881188
}
11891189

1190-
__STATIC_INLINE bool rtc_is_read_safe(void)
1191-
{
1192-
return (RTC->SSR < (255 * 990 / 1000));
1193-
}
1194-
11951190
#elif defined(STM32F1)
11961191

11971192
__STATIC_INLINE void rtc_set_prescaler_factor(uint32_t value)
@@ -1204,24 +1199,28 @@ __STATIC_INLINE void rtc_set_prescaler_factor(uint32_t value)
12041199

12051200
__STATIC_INLINE uint32_t rtc_get_count(void)
12061201
{
1207-
return (RTC->CNTH << 16) | RTC->CNTL;
1202+
uint32_t countHigh1 = RTC->CNTH;
1203+
uint32_t count = RTC->CNTL;
1204+
uint32_t countHigh2 = RTC->CNTH;
1205+
1206+
if (countHigh1 == countHigh2)
1207+
return count | (countHigh1 << 16);
1208+
else
1209+
{
1210+
if (count & 0x8000)
1211+
return count | (countHigh1 << 16);
1212+
else
1213+
return count | (countHigh2 << 16);
1214+
}
12081215
}
12091216

12101217
__STATIC_INLINE void rtc_set_count(uint32_t value)
12111218
{
1219+
RTC->CNTL = 0;
12121220
RTC->CNTH = (value >> 16) & 0xffff;
12131221
RTC->CNTL = value & 0xffff;
12141222
}
12151223

1216-
__STATIC_INLINE bool rtc_is_read_safe(void)
1217-
{
1218-
return (RTC->DIVL < (32767 * 990 / 1000));
1219-
}
1220-
1221-
__STATIC_INLINE void rtc_sync(void)
1222-
{
1223-
}
1224-
12251224
#endif
12261225

12271226
// USART

‎platform.io/platformio.ini

+10-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ build_flags =
1111
-D DISPLAY_MONOCHROME
1212
-D VIBRATOR
1313
-D DATA_MODE
14-
debug_build_flags =
14+
debug_build_flags =
1515
-Og -g2 -ggdb2
1616
-D DEBUG
1717
lib_ignore = libusb_stm32
@@ -29,7 +29,7 @@ build_flags =
2929
-D DISPLAY_MONOCHROME
3030
-D VIBRATOR
3131
-D DATA_MODE
32-
debug_build_flags =
32+
debug_build_flags =
3333
-Og -g2 -ggdb2
3434
-D DEBUG
3535
lib_ignore = libusb_stm32
@@ -47,7 +47,7 @@ build_flags =
4747
-D DISPLAY_MONOCHROME
4848
-D VIBRATOR
4949
-D DATA_MODE
50-
debug_build_flags =
50+
debug_build_flags =
5151
-Og -g2 -ggdb2
5252
-D DEBUG
5353
lib_ignore = libusb_stm32
@@ -65,7 +65,7 @@ build_flags =
6565
-D DISPLAY_128X64
6666
-D DISPLAY_MONOCHROME
6767
-D PULSE_LED
68-
debug_build_flags =
68+
debug_build_flags =
6969
-Og -g2 -ggdb2
7070
-D DEBUG
7171
lib_ignore = libusb_stm32
@@ -82,7 +82,7 @@ build_flags =
8282
-D DISPLAY_128X64
8383
-D DISPLAY_MONOCHROME
8484
-D PULSE_LED
85-
debug_build_flags =
85+
debug_build_flags =
8686
-Og -g2 -ggdb2
8787
-D DEBUG
8888
lib_ignore = libusb_stm32
@@ -94,14 +94,15 @@ framework = cmsis
9494
build_flags =
9595
-D GC01
9696
-D GC01_DISPLAY_SPI
97-
; -D GC01_USART
9897
-D KEYBOARD_5KEYS
9998
-D DISPLAY_320X240
10099
-D DISPLAY_COLOR
101100
-D DISPLAY_FONT_2BPP
102101
-D PULSE_LED
103102
-D VIBRATOR
104-
debug_build_flags =
103+
; -D GC01_USART
104+
-D USBD_ASM_DRIVER
105+
debug_build_flags =
105106
-Og -g2 -ggdb2
106107
-D DEBUG
107108
board_build.ldscript = scripts/gc01.ld
@@ -121,7 +122,7 @@ build_flags =
121122
-D VIBRATOR
122123
-D USBD_ASM_DRIVER
123124
-D DATA_MODE
124-
debug_build_flags =
125+
debug_build_flags =
125126
-Og -g2 -ggdb2
126127
-D DEBUG
127128
board_build.ldscript = scripts/gc01.ld
@@ -140,7 +141,7 @@ build_flags =
140141
-D PULSE_LED
141142
-D VIBRATOR
142143
-D USBD_ASM_DRIVER
143-
debug_build_flags =
144+
debug_build_flags =
144145
-Og -g2 -ggdb2
145146
-D DEBUG
146147
board_build.ldscript = scripts/gc01.ld

‎platform.io/src/datalog.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ static struct
3636
uint8_t buffer[DATALOG_BUFFER_SIZE];
3737

3838
uint8_t lock;
39+
40+
uint32_t lastTimeFast;
3941
} datalog;
4042

4143
static const uint16_t datalogTimeIntervals[] = {
@@ -77,6 +79,8 @@ void initDatalog(void)
7779

7880
while (decodeDatalogEntry(&datalog.writeState))
7981
;
82+
83+
datalog.lastTimeFast = getDeviceTimeFast();
8084
}
8185

8286
static void encodeDatalogValue(int32_t value,
@@ -142,6 +146,11 @@ static void writeDatalogEntry(bool isUpdate)
142146
return;
143147

144148
// Update?
149+
uint32_t timeFast = getDeviceTimeFast();
150+
if (timeFast == datalog.lastTimeFast)
151+
return;
152+
datalog.lastTimeFast = timeFast;
153+
145154
Dose dose;
146155
dose.time = getDeviceTime();
147156
dose.pulseCount = getTubePulseCount();
@@ -158,7 +167,7 @@ static void writeDatalogEntry(bool isUpdate)
158167

159168
bool absoluteEntry = false;
160169

161-
if (!isUpdate || (timeInterval > (sampleInterval + 1)))
170+
if (!isUpdate || (timeInterval > sampleInterval))
162171
{
163172
datalog.writeState.dose.time = dose.time;
164173
datalog.writeState.dose.pulseCount = dose.pulseCount;

‎platform.io/src/events.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#define PULSE_CLICK_LOUD_TICKS ((uint32_t)(0.015 * SYSTICK_FREQUENCY))
3030
#define PULSE_LED_TICKS ((uint32_t)(0.050 * SYSTICK_FREQUENCY))
3131
#define PULSE_FLASH_TICKS ((uint32_t)(0.050 * SYSTICK_FREQUENCY))
32-
#define PULSE_VIBRATION_WEAK_TICKS ((uint32_t)(0.001 * SYSTICK_FREQUENCY))
33-
#define PULSE_VIBRATION_STRONG_TICKS ((uint32_t)(0.015 * SYSTICK_FREQUENCY))
32+
#define PULSE_VIBRATION_WEAK_TICKS ((uint32_t)(0.020 * SYSTICK_FREQUENCY))
33+
#define PULSE_VIBRATION_STRONG_TICKS ((uint32_t)(0.050 * SYSTICK_FREQUENCY))
3434
#define ALARM_TICKS ((uint32_t)(0.100 * SYSTICK_FREQUENCY))
3535
#define ALARM_FLASH_TICKS ((uint32_t)(0.200 * SYSTICK_FREQUENCY))
3636

@@ -258,14 +258,14 @@ void dispatchEvents(void)
258258
sleep(0);
259259

260260
dispatchCommEvents();
261+
updateDatalog();
261262

262263
uint32_t periodUpdate = events.measurementPeriodUpdate;
263264
if (events.lastMeasurementPeriodUpdate != periodUpdate)
264265
{
265266
events.lastMeasurementPeriodUpdate = periodUpdate;
266267

267268
updateMeasurements();
268-
updateDatalog();
269269
updateADC();
270270
updateGame();
271271
updateView();

0 commit comments

Comments
 (0)