├── .gitignore
├── EEVBlog
├── .cproject
├── .gitignore
├── .mxproject
├── .osx.project
├── .project
├── .settings
│ └── language.settings.xml
├── 0start
│ └── startup_stm32l152xd.s
├── 88mph
│ ├── acquisition
│ │ ├── acq_mode_basic.c
│ │ ├── acq_mode_basic.h
│ │ ├── acq_modes.c
│ │ ├── acq_modes.h
│ │ ├── acquisition.c
│ │ ├── acquisition.h
│ │ └── reading.h
│ ├── hardware
│ │ ├── buttons.c
│ │ ├── buttons.h
│ │ ├── gpio.h
│ │ ├── hy3131.c
│ │ ├── hy3131.h
│ │ ├── lcd.c
│ │ ├── lcd.h
│ │ ├── lcd_segments.h
│ │ ├── lcd_tables.c
│ │ └── lcd_tables.h
│ ├── measurement
│ │ ├── meas_mode_basic.c
│ │ ├── meas_mode_basic.h
│ │ ├── meas_modes.c
│ │ ├── meas_modes.h
│ │ ├── measurement.c
│ │ └── measurement.h
│ └── system
│ │ ├── job.c
│ │ ├── job.h
│ │ ├── system.c
│ │ ├── system.h
│ │ ├── timer.c
│ │ └── timer.h
├── Drivers
│ ├── CMSIS
│ │ ├── Device
│ │ │ └── ST
│ │ │ │ └── STM32L1xx
│ │ │ │ └── Include
│ │ │ │ ├── stm32l152xd.h
│ │ │ │ ├── stm32l1xx.h
│ │ │ │ └── system_stm32l1xx.h
│ │ └── Include
│ │ │ ├── arm_common_tables.h
│ │ │ ├── arm_const_structs.h
│ │ │ ├── arm_math.h
│ │ │ ├── cmsis_armcc.h
│ │ │ ├── cmsis_armcc_V6.h
│ │ │ ├── cmsis_gcc.h
│ │ │ ├── core_cm0.h
│ │ │ ├── core_cm0plus.h
│ │ │ ├── core_cm3.h
│ │ │ ├── core_cm4.h
│ │ │ ├── core_cm7.h
│ │ │ ├── core_cmFunc.h
│ │ │ ├── core_cmInstr.h
│ │ │ ├── core_cmSimd.h
│ │ │ ├── core_sc000.h
│ │ │ └── core_sc300.h
│ └── STM32L1xx_HAL_Driver
│ │ ├── Inc
│ │ ├── Legacy
│ │ │ └── stm32_hal_legacy.h
│ │ ├── stm32l1xx_hal.h
│ │ ├── stm32l1xx_hal_adc.h
│ │ ├── stm32l1xx_hal_adc_ex.h
│ │ ├── stm32l1xx_hal_cortex.h
│ │ ├── stm32l1xx_hal_def.h
│ │ ├── stm32l1xx_hal_dma.h
│ │ ├── stm32l1xx_hal_flash.h
│ │ ├── stm32l1xx_hal_flash_ex.h
│ │ ├── stm32l1xx_hal_flash_ramfunc.h
│ │ ├── stm32l1xx_hal_gpio.h
│ │ ├── stm32l1xx_hal_gpio_ex.h
│ │ ├── stm32l1xx_hal_lcd.h
│ │ ├── stm32l1xx_hal_pwr.h
│ │ ├── stm32l1xx_hal_pwr_ex.h
│ │ ├── stm32l1xx_hal_rcc.h
│ │ ├── stm32l1xx_hal_rcc_ex.h
│ │ ├── stm32l1xx_hal_rtc.h
│ │ ├── stm32l1xx_hal_rtc_ex.h
│ │ ├── stm32l1xx_hal_sd.h
│ │ ├── stm32l1xx_hal_tim.h
│ │ ├── stm32l1xx_hal_tim_ex.h
│ │ ├── stm32l1xx_hal_uart.h
│ │ └── stm32l1xx_ll_sdmmc.h
│ │ └── Src
│ │ ├── stm32l1xx_hal.c
│ │ ├── stm32l1xx_hal_adc.c
│ │ ├── stm32l1xx_hal_adc_ex.c
│ │ ├── stm32l1xx_hal_cortex.c
│ │ ├── stm32l1xx_hal_dma.c
│ │ ├── stm32l1xx_hal_flash.c
│ │ ├── stm32l1xx_hal_flash_ex.c
│ │ ├── stm32l1xx_hal_flash_ramfunc.c
│ │ ├── stm32l1xx_hal_gpio.c
│ │ ├── stm32l1xx_hal_lcd.c
│ │ ├── stm32l1xx_hal_pwr.c
│ │ ├── stm32l1xx_hal_pwr_ex.c
│ │ ├── stm32l1xx_hal_rcc.c
│ │ ├── stm32l1xx_hal_rcc_ex.c
│ │ ├── stm32l1xx_hal_rtc.c
│ │ ├── stm32l1xx_hal_rtc_ex.c
│ │ ├── stm32l1xx_hal_sd.c
│ │ ├── stm32l1xx_hal_tim.c
│ │ ├── stm32l1xx_hal_tim_ex.c
│ │ ├── stm32l1xx_hal_uart.c
│ │ └── stm32l1xx_ll_sdmmc.c
├── EEVBlog Debug.cfg
├── EEVBlog.ioc
├── EEVBlog.xml
├── Inc
│ ├── bsp_driver_sd.h
│ ├── fatfs.h
│ ├── ffconf.h
│ ├── main.h
│ ├── stm32l1xx_hal_conf.h
│ └── stm32l1xx_it.h
├── Middlewares
│ └── Third_Party
│ │ └── FatFs
│ │ └── src
│ │ ├── diskio.c
│ │ ├── diskio.h
│ │ ├── drivers
│ │ ├── sd_diskio.c
│ │ └── sd_diskio.h
│ │ ├── ff.c
│ │ ├── ff.h
│ │ ├── ff_gen_drv.c
│ │ ├── ff_gen_drv.h
│ │ ├── ffconf_template.h
│ │ ├── integer.h
│ │ └── option
│ │ └── syscall.c
├── STM32L152ZDTx_FLASH.ld
└── Src
│ ├── bsp_driver_sd.c
│ ├── fatfs.c
│ ├── main.c
│ ├── stm32l1xx_hal_msp.c
│ ├── stm32l1xx_it.c
│ └── system_stm32l1xx.c
├── LICENSE
├── NOTICE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
--------------------------------------------------------------------------------
/EEVBlog/.gitignore:
--------------------------------------------------------------------------------
1 | /Debug/
2 |
--------------------------------------------------------------------------------
/EEVBlog/.mxproject:
--------------------------------------------------------------------------------
1 | [PreviousGenFiles]
2 | HeaderPath=/Users/thomaswatson/projects/121gw/121gw-88mph/EEVBlog/Inc
3 | HeaderFiles=ffconf.h;bsp_driver_sd.h;fatfs.h;stm32l1xx_it.h;stm32l1xx_hal_conf.h;main.h;
4 | SourcePath=/Users/thomaswatson/projects/121gw/121gw-88mph/EEVBlog/Src
5 | SourceFiles=bsp_driver_sd.c;fatfs.c;stm32l1xx_it.c;stm32l1xx_hal_msp.c;main.c;
6 |
7 | [PreviousLibFiles]
8 | LibFiles=Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_adc.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_adc_ex.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_lcd.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_rtc.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_rtc_ex.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_sd.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_ll_sdmmc.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_tim.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_tim_ex.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_uart.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal.h;Drivers/STM32L1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_def.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_rcc.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_rcc_ex.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_flash.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_flash_ex.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_flash_ramfunc.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_gpio.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_gpio_ex.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_dma_ex.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_dma.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_pwr.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_pwr_ex.h;Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_cortex.h;Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.h;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_adc.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_adc_ex.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_lcd.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rtc.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rtc_ex.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_sd.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_ll_sdmmc.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_tim.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_tim_ex.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_uart.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rcc.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rcc_ex.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_flash.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_flash_ex.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_flash_ramfunc.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_gpio.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dma.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_pwr.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_pwr_ex.c;Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_cortex.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.c;Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l152xd.h;Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l1xx.h;Drivers/CMSIS/Device/ST/STM32L1xx/Include/system_stm32l1xx.h;Drivers/CMSIS/Device/ST/STM32L1xx/Source/Templates/system_stm32l1xx.c;Middlewares/Third_Party/FatFs/src/diskio.h;Middlewares/Third_Party/FatFs/src/ffconf_template.h;Middlewares/Third_Party/FatFs/src/ff.h;Middlewares/Third_Party/FatFs/src/integer.h;Middlewares/Third_Party/FatFs/src/ff_gen_drv.h;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/diskio.c;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cmSimd.h;
9 |
10 | [PreviousUsedSW4STM32Files]
11 | SourceFiles=../Src/main.c;../Src/bsp_driver_sd.c;../Src/fatfs.c;../Src/stm32l1xx_it.c;../Src/stm32l1xx_hal_msp.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_adc.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_adc_ex.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_lcd.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rtc.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rtc_ex.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_sd.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_ll_sdmmc.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_tim.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_tim_ex.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_uart.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rcc.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rcc_ex.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_flash.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_flash_ex.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_flash_ramfunc.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_gpio.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dma.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_pwr.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_pwr_ex.c;../Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_cortex.c;../Middlewares/Third_Party/FatFs/src/option/syscall.c;../Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.c;../Middlewares/Third_Party/FatFs/src/ff.c;../Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;../Middlewares/Third_Party/FatFs/src/diskio.c;..//Src/system_stm32l1xx.c;../Drivers/CMSIS/Device/ST/STM32L1xx/Source/Templates/system_stm32l1xx.c;null;../Middlewares/Third_Party/FatFs/src/option/syscall.c;../Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.c;../Middlewares/Third_Party/FatFs/src/ff.c;../Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;../Middlewares/Third_Party/FatFs/src/diskio.c;
12 | HeaderPath=../Drivers/STM32L1xx_HAL_Driver/Inc;../Drivers/STM32L1xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FatFs/src/drivers;../Drivers/CMSIS/Device/ST/STM32L1xx/Include;../Middlewares/Third_Party/FatFs/src;../Drivers/CMSIS/Include;../Inc;
13 | CDefines=__weak:"__attribute__((weak))";__packed:"__attribute__((__packed__))";
14 |
15 |
--------------------------------------------------------------------------------
/EEVBlog/.osx.project:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tpwrules/121gw-88mph/5b42a2438c7455c65d4678885089c44edbdbc351/EEVBlog/.osx.project
--------------------------------------------------------------------------------
/EEVBlog/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | EEVBlog
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
25 | fr.ac6.mcu.ide.core.MCUProjectNature
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/EEVBlog/.settings/language.settings.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/EEVBlog/88mph/acquisition/acq_mode_basic.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #include
20 | #include
21 |
22 | #include "acquisition/acq_mode_basic.h"
23 |
24 | #include "acquisition/acq_modes.h"
25 | #include "acquisition/acquisition.h"
26 | #include "acquisition/reading.h"
27 | #include "system/timer.h"
28 | #include "hardware/hy3131.h"
29 |
30 | // registers for volts dc
31 | // first dimension is submode, second is register
32 |
33 | static const uint8_t volts_dc_regs[4][20] = {
34 | // DCV 5.0000V
35 | { 0, 0,0x13,0x8A, 5,0x40, 0,0x4D,0x31, 1,
36 | 0x22, 0, 0,0x90,0x28,0xA0,0x80,0xC7, 0,0x20},
37 | // DCV 50.000V
38 | { 0, 0,0x13,0x8A, 5,0x40, 0,0x4D,0x31, 1,
39 | 0x22, 0, 0, 9,0x28,0xA0,0x80,0xC7, 8,0x2C},
40 | // DCV 500.00V
41 | { 0, 0,0x13,0x8A, 5,0x40, 0,0x4D,0x31, 1,
42 | 0x22, 0,0x90, 0,0x28,0xA0,0x80,0xC7, 8,0x2C},
43 | // DCV 1000.0V (600.0V)
44 | { 0, 0,0x13,0x8A, 5,0x40, 0,0x4D,0x31, 1,
45 | 0x22, 0, 9, 0,0x28,0xA0,0x80,0xC7, 8,0x2C}
46 | };
47 |
48 | void acq_mode_func_volts_dc(acq_event_t event, int64_t value) {
49 | static acq_submode_t submode = 0;
50 |
51 | switch (event) {
52 | case ACQ_EVENT_START:
53 | case ACQ_EVENT_SET_SUBMODE: {
54 | // starting and setting submodes is the same
55 | // clear acquisitions that aren't for this mode
56 | acq_clear_readings();
57 | // program new register set into the HY3131
58 | submode = (acq_submode_t)value;
59 | hy_write_regs(0x20, 20,
60 | &volts_dc_regs[submode][0]);
61 | // enable the AD1 interrupt so we can display the measurement
62 | acq_set_int_mask(HY_REG_INT_AD1);
63 | break;
64 | }
65 |
66 | case ACQ_EVENT_NEW_AD1: {
67 | int32_t ad1 = (int32_t)value;
68 | // ad1 is already nice and sign extended
69 | // all we need to do is put it into a reading
70 | reading_t reading = {
71 | // approximately calibrate by dividing by 60
72 | (ad1*100)/6, // millicounts
73 | timer_1ms_ticks, // time_ms
74 | RDG_UNIT_VOLTS, // unit
75 | RDG_EXPONENT_NONE, // exponent
76 | // conveniently, decimal point loc is the same as the submode
77 | submode, // decimal point
78 | RDG_KIND_MAIN // kind
79 | };
80 |
81 | // tell the new reading to the measurement engine
82 | acq_put_reading(&reading);
83 | break;
84 | }
85 |
86 | case ACQ_EVENT_STOP: {
87 | acq_set_int_mask(0x00);
88 | break;
89 | }
90 |
91 | default: {
92 | break;
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/EEVBlog/88mph/acquisition/acq_mode_basic.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef ACQUISITION_ACQ_MODE_BASIC_H
20 | #define ACQUISITION_ACQ_MODE_BASIC_H
21 |
22 | #include
23 |
24 | #include "acquisition/acq_modes.h"
25 |
26 | // this file defines the acquisition mode funcs for the boring modes
27 | // volts, etc
28 |
29 | void acq_mode_func_volts_dc(acq_event_t event, int64_t value);
30 |
31 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/acquisition/acq_modes.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | // pointers to the acquisition mode functions
20 |
21 | #include "acquisition/acq_modes.h"
22 |
23 | #include "acquisition/acquisition.h"
24 | #include "acquisition/acq_mode_basic.h"
25 |
26 | const acq_mode_func acq_mode_funcs[2] = {
27 | // ACQ_MODE_MISC
28 | acq_mode_func_misc,
29 | // ACQ_MODE_VOLTS_DC
30 | acq_mode_func_volts_dc
31 | };
--------------------------------------------------------------------------------
/EEVBlog/88mph/acquisition/acq_modes.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef ACQUISITION_ACQ_MODES_H
20 | #define ACQUISITION_ACQ_MODES_H
21 |
22 | #include
23 |
24 | // this file defines the acquisition modes and submodes
25 | // the corresponding .c has a table with function pointers to the mode handlers
26 | // keep the ordering of these options the same!
27 |
28 | typedef enum {
29 | ACQ_MODE_MISC=0,
30 | ACQ_MODE_VOLTS_DC
31 | } acq_mode_t;
32 |
33 | // each mode starts its submodes at 0!!!
34 | typedef enum {
35 | ACQ_MODE_MISC_SUBMODE_OFF=0,
36 |
37 | ACQ_MODE_VOLTS_DC_SUBMODE_5d0000=0,
38 | ACQ_MODE_VOLTS_DC_SUBMODE_50d000,
39 | ACQ_MODE_VOLTS_DC_SUBMODE_500d00,
40 | ACQ_MODE_VOLTS_DC_SUBMODE_1000d0
41 |
42 | } acq_submode_t;
43 |
44 | // we also need to define the mode function
45 | // this function will not be re-entered
46 | typedef enum {
47 | // begin acquiring, value is initial submode
48 | ACQ_EVENT_START=0,
49 | // stop acquiring, value is meaningless
50 | ACQ_EVENT_STOP,
51 | // switch submodes, value is new submode
52 | ACQ_EVENT_SET_SUBMODE,
53 | // new measurement available, value is new measurement
54 | ACQ_EVENT_NEW_AD1
55 | } acq_event_t;
56 |
57 | typedef void (*acq_mode_func)(acq_event_t event, int64_t value);
58 |
59 | extern const acq_mode_func acq_mode_funcs[2];
60 |
61 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/acquisition/acquisition.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | // this file handles the acquisition engine
20 |
21 | #include
22 | #include
23 | #include "stm32l1xx.h"
24 |
25 | #include "acquisition/acquisition.h"
26 |
27 | #include "acquisition/acq_modes.h"
28 | #include "system/job.h"
29 | #include "hardware/hy3131.h"
30 | #include "hardware/gpio.h"
31 |
32 | static acq_mode_func curr_acq_mode_func = 0;
33 | static volatile uint8_t curr_int_mask = 0;
34 |
35 | // turn on the acquisition engine
36 | void acq_init(void) {
37 | // power up the digital supply for the measurement
38 | GPIO_PINSET(HW_PWR_CTL);
39 | // turn on the 4V analog supply
40 | GPIO_PINSET(HW_PWR_CTL2);
41 | // give the HY3131 a bit of time to power up
42 | // who knows if this is necessary, but it feels good
43 | HAL_Delay(10);
44 | // initialize it
45 | curr_int_mask = 0;
46 | hy_init();
47 | // switch to the 'off' mode manually
48 | // cause there should be no previous mode func to call
49 | curr_acq_mode_func = acq_mode_funcs[ACQ_MODE_MISC];
50 | curr_acq_mode_func(ACQ_EVENT_START, (int64_t)ACQ_MODE_MISC_SUBMODE_OFF);
51 | // the off mode tells the HY to not send us interrupts
52 | }
53 |
54 | // turn off the acquisition engine
55 | void acq_deinit(void) {
56 | // stop the current acquisition by switching to 'off'
57 | acq_set_mode(ACQ_MODE_MISC, ACQ_MODE_MISC_SUBMODE_OFF);
58 | // and cancel out the acq function
59 | curr_acq_mode_func = 0;
60 | // stop the HY3131
61 | hy_deinit();
62 | // turn off analog supply
63 | GPIO_PINRST(HW_PWR_CTL2);
64 | // and then digital supply
65 | GPIO_PINRST(HW_PWR_CTL);
66 | }
67 |
68 | // do the acquisition job
69 | // check the HY3131 and calculate new acquisitions
70 | void acq_handle_job_acquisition(void) {
71 | uint8_t regbuf[5];
72 |
73 | // read which interrupts are pending
74 | // this also clears the pending interrupts
75 | uint8_t which_ints;
76 | hy_read_regs(HY_REG_INTF, 1, &which_ints);
77 | // only handle pending interrupts which are enabled
78 | which_ints &= curr_int_mask;
79 | if (which_ints & HY_REG_INT_AD1) {
80 | // read the 24 bit AD1 register
81 | hy_read_regs(HY_REG_AD1_DATA, 3, regbuf);
82 | int32_t val = regbuf[2] << 16 | regbuf[1] << 8 | regbuf[0];
83 | // sign extend 24 bits to 32
84 | if (val & 0x800000) {
85 | val |= 0xFF000000;
86 | }
87 | // tell the current acquisition mode about it
88 | curr_acq_mode_func(ACQ_EVENT_NEW_AD1, val);
89 | }
90 | }
91 |
92 | void acq_set_int_mask(uint8_t mask) {
93 | // disable the job around this so curr_int_mask isn't wrong
94 | bool acq_enabled = job_disable(JOB_ACQUISITION);
95 | curr_int_mask = mask;
96 | // the caller probably is changing the int mask because they've reconfigured
97 | // the chip, so clear pending interrupts from the chip first
98 | if (mask) {
99 | uint8_t whatever;
100 | hy_read_regs(HY_REG_INTF, 1, &whatever);
101 | }
102 | // now enable the interrupts the user wanted
103 | hy_write_regs(HY_REG_INTE, 1, &mask);
104 | // and turn on the job again so they get handled
105 | job_resume(JOB_ACQUISITION, acq_enabled);
106 | }
107 |
108 | void acq_set_mode(acq_mode_t mode, acq_submode_t submode) {
109 | // the acq job might try to interrupt us during this process, so pause it
110 | bool acq_enabled = job_disable(JOB_ACQUISITION);
111 | // turn off the current mode
112 | curr_acq_mode_func(ACQ_EVENT_STOP, 0);
113 | // figure out which mode func goes with this mode
114 | curr_acq_mode_func = acq_mode_funcs[mode];
115 | // and start it up
116 | curr_acq_mode_func(ACQ_EVENT_START, (int64_t)submode);
117 | job_resume(JOB_ACQUISITION, acq_enabled);
118 | }
119 |
120 | void acq_set_submode(acq_submode_t submode) {
121 | // the acq job might try to interrupt us during this process, so pause it
122 | bool acq_enabled = job_disable(JOB_ACQUISITION);
123 | curr_acq_mode_func(ACQ_EVENT_SET_SUBMODE, (int64_t)submode);
124 | job_resume(JOB_ACQUISITION, acq_enabled);
125 | }
126 |
127 | // must be power of 2!!
128 | #define ACQ_READING_QUEUE_SIZE (8)
129 |
130 | #define Q_MASK (ACQ_READING_QUEUE_SIZE-1)
131 |
132 | static volatile reading_t queue[ACQ_READING_QUEUE_SIZE];
133 | static volatile int q_head = 0;
134 | static volatile int q_tail = 0;
135 |
136 | // put a reading into the queue. if there is no space it's just dropped
137 | void acq_put_reading(reading_t* reading) {
138 | // can be called from any job, so protect ourselves!
139 | __disable_irq();
140 | // buffer head cause it's volatile
141 | // but we know we can't get interrupted
142 | int q_h = q_head;
143 | if (((q_h+1)&Q_MASK) != q_tail) {
144 | // we have space
145 | queue[q_h] = *reading;
146 | q_head = (q_h+1) & Q_MASK;
147 | }
148 | __enable_irq();
149 |
150 | // the measurement engine is certainly interested in this new reading
151 | job_schedule(JOB_MEASUREMENT);
152 | }
153 |
154 | // get a reading from the queue. returns false if there is no reading to get.
155 | // else puts the reading into reading and returns true
156 | bool acq_get_reading(reading_t* reading) {
157 | // can be called from any job, so protect ourselves!
158 | __disable_irq();
159 | // buffer tail cause it's volatile
160 | // but we know we can't get interrupted
161 | int q_t = q_tail;
162 | bool there_is_a_reading = (q_head != q_t);
163 | if (there_is_a_reading) {
164 | *reading = queue[q_t];
165 | q_tail = (q_t+1) & Q_MASK;
166 | }
167 | __enable_irq();
168 | return there_is_a_reading;
169 | }
170 |
171 | // empty the queue of all readings
172 | void acq_clear_readings(void) {
173 | // can be called from any job, so protect ourselves!
174 | __disable_irq();
175 | q_head = 0;
176 | q_tail = 0;
177 | __enable_irq();
178 | }
179 |
180 | // misc mode handler
181 | void acq_mode_func_misc(acq_event_t event, int64_t value) {
182 | // for now, all this mode should be doing is turning off
183 | acq_set_int_mask(0);
184 | acq_clear_readings();
185 | }
--------------------------------------------------------------------------------
/EEVBlog/88mph/acquisition/acquisition.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef ACQUISITION_ACQUISITION_H
20 | #define ACQUISITION_ACQUISITION_H
21 |
22 | #include
23 | #include
24 |
25 | #include "acquisition/reading.h"
26 | #include "acquisition/acq_modes.h"
27 |
28 | // turn on the acquisition engine
29 | void acq_init(void);
30 | // turn off the acquisition engine
31 | void acq_deinit(void);
32 |
33 | // do the acquisition job
34 | // check the HY3131 and calculate new acquisitions
35 | void acq_handle_job_acquisition(void);
36 |
37 | // set the HY interrupt mask register
38 | void acq_set_int_mask(uint8_t mask);
39 |
40 |
41 | // set acquisition state
42 | void acq_set_mode(acq_mode_t mode, acq_submode_t submode);
43 | void acq_set_submode(acq_submode_t submode);
44 |
45 | // there is a queue of acquired values, effectively between the acquisition
46 | // job and the measurement job
47 | // put a reading into the queue. if there is no space it's just dropped
48 | void acq_put_reading(reading_t* reading);
49 | // get a reading from the queue. returns false if there is no reading to get.
50 | // else puts the reading into reading and returns true
51 | bool acq_get_reading(reading_t* reading);
52 | // empty the queue of all readings
53 | void acq_clear_readings(void);
54 |
55 | void acq_mode_func_misc(acq_event_t event, int64_t value);
56 |
57 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/acquisition/reading.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef ACQUISITION_READING_H
20 | #define ACQUISITION_READING_H
21 |
22 | #include
23 |
24 | // this file introduces the concept of a Reading
25 |
26 | // a Reading is associated with a unit
27 | // note that the table lcd_unit_icons is in this order
28 | typedef enum {
29 | RDG_UNIT_NONE=0,
30 | RDG_UNIT_AMPS,
31 | RDG_UNIT_PERCENT,
32 | RDG_UNIT_FARADS,
33 | RDG_UNIT_HERTZ,
34 | RDG_UNIT_SECONDS,
35 | RDG_UNIT_OHMS,
36 | RDG_UNIT_VOLTS,
37 | RDG_UNIT_DEG_C,
38 | RDG_UNIT_DEG_F,
39 | RDG_UNIT_dB
40 | } rdg_unit_t;
41 |
42 | // this controls which exponent lights up on the LCD
43 | // note that the table lcd_exponent_icons is in this order
44 | typedef enum {
45 | RDG_EXPONENT_NANO=0,
46 | RDG_EXPONENT_MICRO,
47 | RDG_EXPONENT_MILLI,
48 | RDG_EXPONENT_NONE, // no exponent
49 | RDG_EXPONENT_KILO,
50 | RDG_EXPONENT_MEGA
51 | } rdg_exponent_t;
52 |
53 | // this controls which decimal point lights up on the LCD
54 | // note that the table lcd_decimal_points is in this order
55 | typedef enum {
56 | RDG_DECIMAL_1d0000=0,
57 | RDG_DECIMAL_10d000,
58 | RDG_DECIMAL_100d00,
59 | RDG_DECIMAL_1000d0,
60 | RDG_DECIMAL_10000 // no decimal
61 | } rdg_decimal_t;
62 |
63 | // this controls the reading's kind, and thus its fate
64 | typedef enum {
65 | RDG_KIND_MAIN, // main screen reading
66 | } rdg_kind_t;
67 |
68 | typedef struct {
69 | // the value of the reading
70 | // one count -> one least significant digit display
71 | // thus the reading can be 1000 times more precise in calculations
72 | int32_t millicounts;
73 | // the milliseconds the reading was taken at
74 | // used for logging purposes
75 | uint32_t time_ms;
76 | // the base unit of the reading
77 | rdg_unit_t unit;
78 | // the unit's exponent and decimal position
79 | // there is no requirement that these be normalized
80 | // i.e. 1000.0V and 1.0000kV are both allowed, but will have different
81 | // values here
82 | rdg_exponent_t exponent;
83 | rdg_decimal_t decimal;
84 | // what the reading's purpose is in life
85 | rdg_kind_t kind;
86 | } reading_t;
87 |
88 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/hardware/buttons.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef HARDWARE_BUTTONS_H
20 | #define HARDWARE_BUTTONS_H
21 |
22 | // this file handles reading the buttons, debouncing them, and
23 | // determining held-ness
24 |
25 | // how long a button is pressed before it's considered held
26 | // in 10ms units, max 255
27 | #define BTN_HELD_TIME (100) // 1 second
28 |
29 | typedef enum {
30 | // finger off the button
31 | BTN_RELEASED = 0,
32 | // finger on the button
33 | BTN_PRESSED = 1,
34 | // finger on the button for at least BTN_HELD_TIME
35 | // (if the button can be held)
36 | BTN_HELD = 2,
37 | } button_state_t;
38 |
39 | // the buttons! finally
40 | // do not change the order!!
41 | // the rest of the data is in a table in buttons.c
42 | typedef enum {
43 | // nothing was pressed or held
44 | BTN_NONE = 0,
45 |
46 | // top row, left to right
47 | BTN_RANGE,
48 | BTN_HOLD,
49 | BTN_REL,
50 | BTN_1ms_PEAK,
51 |
52 | // bottom row, left to right
53 | BTN_MODE,
54 | BTN_MIN_MAX,
55 | BTN_MEM,
56 | BTN_SETUP,
57 |
58 | // if something is in the corresponding jack
59 | BTN_JACKDET_mA,
60 | BTN_JACKDET_A,
61 |
62 | // range switch, left to right
63 | BTN_RSW_LowZ,
64 | BTN_RSW_V,
65 | BTN_RSW_mV,
66 | BTN_RSW_Hz,
67 | BTN_RSW_OHMS,
68 | BTN_RSW_VA,
69 | BTN_RSW_uA,
70 | BTN_RSW_A
71 | } button_t;
72 |
73 | // called every 10ms to do all the magic
74 | void btn_process(void);
75 |
76 | // looks at the non-range-switch buttons and returns the first one whose state
77 | // is new. it then clears the new flag and stores the state in new_state
78 | // if there is no such button, returns BTN_NONE and does not change new_state
79 | button_t btn_get_new(button_state_t* new_state);
80 |
81 | // returns the state of the corresponding button and clears the new flag
82 | // always returns BTN_RELEASED for BTN_NONE
83 | button_state_t btn_get_state(button_t button);
84 |
85 | // get the position of the range switch.
86 | // returns BTN_NONE if 0 or more than 1 switch position is selected
87 | button_t btn_get_rsw(void);
88 |
89 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/hardware/gpio.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef HARDWARE_GPIO_H
20 | #define HARDWARE_GPIO_H
21 |
22 | // this file just has some GPIO-related macros
23 | // because I'm not so fond of the HAL ones
24 | // it's designed to work with cube-generated pin names
25 |
26 | #include
27 |
28 | #include "stm32l1xx.h"
29 |
30 | // get all the cube pin definitions
31 | #include "main.h"
32 |
33 | // set a pin to 1
34 | #define GPIO_PINSET(pin) \
35 | GPIO_PINCHG(pin, 1)
36 | // reset a pin to 0
37 | #define GPIO_PINRST(pin) \
38 | GPIO_PINCHG(pin, 0)
39 | // change pin state depending on predicate
40 | #define GPIO_PINCHG(pin, predicate) \
41 | do {*GPIO_PINCHG_BITBAND_ADDR(pin) = (predicate);} while(0)
42 |
43 | // return 1 or 0 depending on pin state
44 | // the ternary for 1/0 should be a noop since it's already a bool
45 | // but this will allow a wider type, if advantageous
46 | #define GPIO_PINGET(pin) \
47 | ((*GPIO_PINGET_BITBAND_ADDR(pin)) ? 1 : 0)
48 |
49 | // calculate a pointer to a bool that represents the specific
50 | // GPIO output state
51 | #define GPIO_PINCHG_BITBAND_ADDR(pin) \
52 | ((BITBAND_PERIPH(&(pin ## _GPIO_Port->ODR), POSITION_VAL(pin ## _Pin))))
53 |
54 | // calculate a pointer to a bool that represents the specific
55 | // GPIO input state
56 | #define GPIO_PINGET_BITBAND_ADDR(pin) \
57 | ((BITBAND_PERIPH(&(pin ## _GPIO_Port->IDR), POSITION_VAL(pin ## _Pin))))
58 |
59 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/hardware/hy3131.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #include
20 | #include
21 | #include "stm32l1xx.h"
22 |
23 | #include "hardware/hy3131.h"
24 |
25 | #include "hardware/gpio.h"
26 | #include "system/job.h"
27 | #include "acquisition/acquisition.h"
28 |
29 | static void check_irq_line(void) {
30 | // the EXTI interrupt line is edge-sensitive
31 | // so if we turn on interrupts while the HY has already asserted
32 | // the interrupt line, we will never catch it
33 | // also, communicating with the HY will wiggle the DO line and trigger
34 | // spurious interrupts
35 |
36 | __disable_irq();
37 | // clear pending and perhaps fake EXTI interrupt
38 | EXTI->PR = EXTI_PR_PR3;
39 | // clear pending NVIC interrupt that would have happened as a result
40 | NVIC_ClearPendingIRQ((IRQn_Type)JOB_ACQUISITION);
41 | // check if the interrupt line is asserted
42 | if (GPIO_PINGET(HY_DO)) {
43 | // if it is, manually assert the interrupt in EXTI
44 | // as if it had seen the edge
45 | EXTI->SWIER = EXTI_SWIER_SWIER3;
46 | }
47 | __enable_irq();
48 | }
49 |
50 | void hy_init(void) {
51 | // set up the interrupt handler
52 | // the chip DO line is connected to PF3, so it's on the EXTI3 line
53 |
54 | // disable the job so interrupts start off disabled
55 | job_disable(JOB_ACQUISITION);
56 |
57 | // configure EXTI3 to monitor the F pin
58 | MODIFY_REG(SYSCFG->EXTICR[0], // this EXTICR starts at 0 unlike the docs >_>
59 | SYSCFG_EXTICR1_EXTI3,
60 | SYSCFG_EXTICR1_EXTI3_PF);
61 |
62 | // enable the rising edge interrupt
63 | SET_BIT(EXTI->RTSR, EXTI_RTSR_TR3);
64 |
65 | // and unmask the interrupt so the NVIC sees it
66 | SET_BIT(EXTI->IMR, EXTI_IMR_MR3);
67 |
68 | // finally, clear the interrupt mask inside the chip
69 | // this will also properly set up the interrupt state
70 | uint8_t mask = 0;
71 | hy_write_regs(HY_REG_INTE, 1, &mask);
72 | }
73 |
74 | void hy_deinit(void) {
75 | job_disable(JOB_ACQUISITION);
76 | }
77 |
78 |
79 | // chip interrupt is connected to EXTI3
80 | void EXTI3_IRQHandler(void) {
81 | // acknowledge this interrupt in EXTI
82 | EXTI->PR = EXTI_PR_PR3;
83 |
84 | // it's time to do the job, probably because the HY bothered us
85 | acq_handle_job_acquisition();
86 | }
87 |
88 | // just wait some time to let setup and hold delays happen
89 | static void spinloop(uint32_t times) {
90 | volatile uint32_t detimes = times;
91 | while (detimes--);
92 | }
93 |
94 | static void toggle_clock(void) {
95 | spinloop(1);
96 | GPIO_PINSET(HY_CK);
97 | spinloop(1);
98 | GPIO_PINRST(HY_CK);
99 | }
100 |
101 | static void send_byte(uint8_t byte) {
102 | for (int bit=0; bit<8; bit++) {
103 | GPIO_PINCHG(HY_DI, byte & 0x80);
104 | byte <<= 1;
105 | toggle_clock();
106 | }
107 | }
108 |
109 | static uint8_t recv_byte(void) {
110 | uint8_t byte = 0;
111 | for (int bit=0; bit<8; bit++) {
112 | // toggle clock before reading bit because there is a 1 bit
113 | // turnaround time between sending and receiving
114 | toggle_clock();
115 | byte <<= 1;
116 | byte |= GPIO_PINGET(HY_DO);
117 | }
118 | return byte;
119 | }
120 |
121 | // read a series of registers from the chip
122 | void hy_read_regs(uint8_t start, uint8_t count, uint8_t* data) {
123 | // we have to turn off interrupts while doing this
124 | // because the chip will be wiggling DO and making spurious interrupts
125 | // all over the place
126 | bool acq_enabled = job_disable(JOB_ACQUISITION);
127 |
128 | // assert chip select
129 | GPIO_PINRST(HY_CS);
130 |
131 | // send address and read mode bit
132 | send_byte(start << 1 | 1);
133 |
134 | // shift out zeros
135 | GPIO_PINRST(HY_DI);
136 |
137 | // and now receive the data
138 | for (int ri = 0; ri < count; ri++) {
139 | data[ri] = recv_byte();
140 | }
141 |
142 | // deassert chip select to finish off
143 | GPIO_PINSET(HY_CS);
144 | // wait for DO to stabilize once CS is deasserted
145 | spinloop(1);
146 |
147 | // clear spurious interrupts, but listen to the HY if it wants us
148 | check_irq_line();
149 | // configure the job how it was
150 | job_resume(JOB_ACQUISITION, acq_enabled);
151 | }
152 |
153 | // write a series of registers to the chip
154 | void hy_write_regs(uint8_t start, uint8_t count, const uint8_t* data) {
155 | // we have to turn off interrupts while doing this
156 | // because the chip will be wiggling DO and making spurious interrupts
157 | // all over the place
158 | bool acq_enabled = job_disable(JOB_ACQUISITION);
159 |
160 | // assert chip select
161 | GPIO_PINRST(HY_CS);
162 |
163 | // send address and write mode bit
164 | send_byte(start << 1 | 0);
165 |
166 | // now send the data
167 | for (int ri = 0; ri < count; ri++) {
168 | send_byte(data[ri]);
169 | }
170 |
171 | // deassert chip select and data out to finish off
172 | GPIO_PINSET(HY_CS);
173 | GPIO_PINRST(HY_DI);
174 | // wait for DO to stabilize once CS is deasserted
175 | spinloop(1);
176 |
177 | // clear spurious interrupts, but listen to the HY if it wants us
178 | check_irq_line();
179 | // configure the job how it was
180 | job_resume(JOB_ACQUISITION, acq_enabled);
181 | }
182 |
--------------------------------------------------------------------------------
/EEVBlog/88mph/hardware/hy3131.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef HARDWARE_HY3131_H
20 | #define HARDWARE_HY3131_H
21 |
22 | #include
23 | #include
24 |
25 | // this file manages interacting with the HY3131 measurement chip
26 |
27 | // register defines
28 | // multibyte registers are all sign-extended little endian
29 |
30 | // last AD1 and AD2/3 value
31 | #define HY_REG_AD1_DATA (0x00) // and the next two
32 | #define HY_REG_AD2_DATA (0x03) // and the next two
33 | // last low-pass filter value
34 | #define HY_REG_LPF_DATA (0x06) // and the next two
35 | // last RMS computation value
36 | #define HY_REG_RMS_DATA (0x09) // and the next four
37 | // peak hold minimum value
38 | #define HY_REG_PKHMIN (0x0E) // and the next two
39 | // peak hold maximum value
40 | #define HY_REG_PKHMAX (0x11) // and the next two
41 | // frequency counter status
42 | #define HY_REG_CTSTA (0x14)
43 | #define HY_REG_CTSTA_CTBOV (0x01) // bit set if CTB overflows
44 | // frequency counter registers
45 | #define HY_REG_CTC (0x15) // and the next two
46 | #define HY_REG_CTB (0x18) // and the next two
47 | #define HY_REG_CTA (0x1B) // and the next two
48 | // interrupt flag; 1 when specified interrupt happened
49 | #define HY_REG_INTF (0x1E)
50 | // interrupt enable; 1 to enable specified interrupt
51 | #define HY_REG_INTE (0x1F)
52 |
53 | // BORF: set in INTF when chip detects brown-out
54 | // note that this does not cause an IRQ!
55 | #define HY_REG_INTF_BORF (0x80)
56 | // the other interrupts: enable in INTE, monitor in INTF
57 | #define HY_REG_INT_RMS (0x10)
58 | #define HY_REG_INT_LPF (0x08)
59 | #define HY_REG_INT_AD1 (0x04)
60 | #define HY_REG_INT_AD2 (0x02)
61 | #define HY_REG_INT_CT (0x01)
62 |
63 | void hy_init(void);
64 | void hy_deinit(void);
65 |
66 | // the EXTI3 interrupt is triggered when the chip asserts its IRQ
67 | void EXTI3_IRQHandler(void);
68 |
69 | // read a series of registers from the chip
70 | void hy_read_regs(uint8_t start, uint8_t count, uint8_t* data);
71 | // write a series of registers to the chip
72 | void hy_write_regs(uint8_t start, uint8_t count, const uint8_t* data);
73 |
74 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/hardware/lcd.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #include
20 | #include
21 | #include "stm32l1xx.h"
22 |
23 | #include "hardware/lcd.h"
24 |
25 | #include "hardware/lcd_segments.h"
26 | #include "hardware/lcd_tables.h"
27 |
28 | #include "acquisition/reading.h"
29 |
30 | uint32_t lcd_segment_buffer[8];
31 |
32 | static volatile bool lcd_needs_updating = false;
33 |
34 | void lcd_queue_update(void) {
35 | lcd_needs_updating = true;
36 | }
37 |
38 | // try and update the display every 10ms
39 | // called by the 10ms timer routine
40 | void lcd_10ms_update_if_necessary(void) {
41 | // if the LCD is currently updating, we can't touch it
42 | // so return and it'll get done next interrupt
43 | if (LCD->SR & LCD_SR_UDR)
44 | return;
45 | // fill the LCD RAM with our buffer
46 | for (int i=0; i<8; i++) {
47 | LCD->RAM[i] = lcd_segment_buffer[i];
48 | }
49 | // and set the bit to trigger a new update
50 | LCD->SR |= LCD_SR_UDR;
51 | lcd_needs_updating = false;
52 | }
53 |
54 | // turn off all the units on the selected screen
55 | void lcd_clear_units_powers(lcd_screen_t which) {
56 | for (int i=0; i<11; i++) {
57 | uint8_t seg = lcd_unit_icons[which][i];
58 | if (seg != SEG_NONE)
59 | LCD_SEGOFF(seg);
60 | }
61 |
62 | for (int i=0; i<6; i++) {
63 | uint8_t seg = lcd_exponent_icons[which][i];
64 | if (seg != SEG_NONE)
65 | LCD_SEGOFF(seg);
66 | }
67 |
68 | for (int i=0; i<4; i++) {
69 | LCD_SEGOFF(lcd_decimal_points[which][i]);
70 | }
71 | }
72 |
73 | // set a character on one of the LCD's 7 segment displays
74 | void lcd_set_char(lcd_digit_t where, char c) {
75 | // first step: look up the char and get its segments
76 | uint8_t segs; // in xGFEDCBA order
77 | if (c >= 'A' && c <= 'Z') {
78 | segs = lcd_7seg_font[c-'A'+10];
79 | } else if (c >= 'a' && c <= 'z') {
80 | segs = lcd_7seg_font[c-'a'+10];
81 | } else if (c >= '0' && c <= '9') {
82 | segs = lcd_7seg_font[c-'0'];
83 | } else {
84 | switch (c) {
85 | case '=':
86 | segs = 0x48;
87 | break;
88 | case '-':
89 | segs = 0x40;
90 | break;
91 | case ' ':
92 | default:
93 | segs = 0x00;
94 | }
95 | }
96 |
97 | // now set them accordingly
98 | for (int i=0; i<7; i++) {
99 | LCD_SEGSET(lcd_7seg_segments[(uint8_t)where][i],
100 | segs & 1);
101 | segs >>= 1;
102 | }
103 | }
104 |
105 | // write a string to a screen
106 | // any longer than 5 chars is truncated
107 | // any shorter is set to space
108 | void lcd_put_str(lcd_screen_t which, char* s) {
109 | lcd_digit_t where =
110 | which == LCD_SCREEN_SUB ? LCD_DIGIT_SS_10000 : LCD_DIGIT_MS_10000;
111 |
112 | for (int i=0; i<5; i++) {
113 | char c = *s;
114 | lcd_set_char(where++, c);
115 | if (c)
116 | s++;
117 | }
118 | }
119 |
120 | // put a reading on a screen
121 | // automatically sets the units and powers accordingly
122 | void lcd_put_reading(lcd_screen_t which, reading_t reading) {
123 | // to do: somehow cache the current unit and exponent so that
124 | // we don't have to turn off and on the segments each time
125 |
126 | // but for now, we gotta
127 | lcd_clear_units_powers(which);
128 |
129 | // round reading to display size
130 | int val = (reading.millicounts + 500)/1000;
131 |
132 | // set negative sign
133 | if (which == LCD_SCREEN_MAIN) {
134 | LCD_SEGSET(SEG_MS_NEGATIVE, val < 0);
135 | } else {
136 | LCD_SEGSET(SEG_SS_NEGATIVE, val < 0);
137 | }
138 |
139 | val = (val < 0) ? -val : val;
140 |
141 | // put each digit in its place
142 | lcd_digit_t place =
143 | which == LCD_SCREEN_SUB ? LCD_DIGIT_SS_1 : LCD_DIGIT_MS_1;
144 | for (int di=0; di<5; di++) {
145 | lcd_set_char(place--, (val % 10)+'0');
146 | val /= 10;
147 | }
148 |
149 | // turn on other icons if they exist
150 | uint8_t seg = lcd_unit_icons[which][reading.unit];
151 | if (seg != SEG_NONE) {
152 | LCD_SEGON(seg);
153 | }
154 |
155 | seg = lcd_exponent_icons[which][reading.exponent];
156 | if (seg != SEG_NONE) {
157 | LCD_SEGON(seg);
158 | }
159 |
160 | seg = lcd_decimal_points[which][reading.decimal];
161 | if (seg != SEG_NONE) {
162 | LCD_SEGON(seg);
163 | }
164 | }
--------------------------------------------------------------------------------
/EEVBlog/88mph/hardware/lcd.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef HARDWARE_LCD_H
20 | #define HARDWARE_LCD_H
21 |
22 | /*
23 | This file contains functions to perform tasks on the LCD.
24 | */
25 |
26 | #include
27 |
28 | #include "acquisition/reading.h"
29 |
30 | extern uint32_t lcd_segment_buffer[8];
31 |
32 | // define the digits on the screen for lcd_set_char
33 | // this enum is in the order defined in lcd_7seg_segments
34 | typedef enum {
35 | LCD_DIGIT_SS_10000=0,
36 | LCD_DIGIT_SS_1000=1,
37 | LCD_DIGIT_SS_100=2,
38 | LCD_DIGIT_SS_10=3,
39 | LCD_DIGIT_SS_1=4,
40 |
41 | LCD_DIGIT_MS_10000=5,
42 | LCD_DIGIT_MS_1000=6,
43 | LCD_DIGIT_MS_100=7,
44 | LCD_DIGIT_MS_10=8,
45 | LCD_DIGIT_MS_1=9
46 | } lcd_digit_t;
47 |
48 | // define the main and sub screens for the various put functions
49 | typedef enum {
50 | LCD_SCREEN_SUB=0,
51 | LCD_SCREEN_MAIN=1
52 | } lcd_screen_t;
53 |
54 | // ask for an update from the segment buffer to be done
55 | void lcd_queue_update(void);
56 |
57 | // try and update the display every 10ms
58 | // called by the 10ms timer routine
59 | void lcd_10ms_update_if_necessary(void);
60 |
61 | // turn on and off segments
62 | #define LCD_SEGON(seg) \
63 | LCD_SEGSET(seg, 1)
64 | #define LCD_SEGOFF(seg) \
65 | LCD_SEGSET(seg, 0)
66 | // bit banding enables us to access the segment buffer as just
67 | // a bit array (a 'seg' is just a bit index)
68 | #define LCD_SEGSET(seg, val)\
69 | do {*BITBAND_SRAM(lcd_segment_buffer, (seg)) = (val); } while(0)
70 |
71 | // clear all the units and powers on the selected screen
72 | void lcd_clear_units_powers(lcd_screen_t which);
73 |
74 | // set a character on one of the LCD's 7 segment displays
75 | void lcd_set_char(lcd_digit_t where, char c);
76 | // write a string to a screen
77 | // any longer than 5 chars is truncated
78 | // any shorter is set to space
79 | void lcd_put_str(lcd_screen_t which, char* s);
80 | // put a reading on a screen
81 | // automatically sets the units and powers accordingly
82 | void lcd_put_reading(lcd_screen_t which, reading_t reading);
83 |
84 | #endif
85 |
--------------------------------------------------------------------------------
/EEVBlog/88mph/hardware/lcd_tables.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #include
20 |
21 | #include "hardware/lcd_tables.h"
22 |
23 | #include "hardware/lcd_segments.h"
24 |
25 | // table to map letters and numbers to segments
26 | // each byte is in xGFEDCBA order
27 | const uint8_t lcd_7seg_font[36] = {
28 | 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, // 0-5
29 | 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, // 6-9, A-B
30 | 0x39, 0x5e, 0x79, 0x71, 0x6f, 0x76, // C-H
31 | 0x30, 0x0e, 0x75, 0x38, 0x55, 0x54, // I-N
32 | 0x5c, 0x73, 0x67, 0x50, 0x6d, 0x78, // O-T
33 | 0x3e, 0x1c, 0x1d, 0x64, 0x6e, 0x1b // U-Z
34 | };
35 |
36 | // table to map 7 segment segments to the screen
37 | // 0-4: sub screen, left to right
38 | // 5-9: main screen, left to right
39 | const uint8_t lcd_7seg_segments[10][7] = {
40 | {SEG_SS_10000_A, SEG_SS_10000_B, SEG_SS_10000_C, SEG_SS_10000_D,
41 | SEG_SS_10000_E, SEG_SS_10000_F, SEG_SS_10000_G},
42 | {SEG_SS_1000_A, SEG_SS_1000_B, SEG_SS_1000_C, SEG_SS_1000_D,
43 | SEG_SS_1000_E, SEG_SS_1000_F, SEG_SS_1000_G},
44 | {SEG_SS_100_A, SEG_SS_100_B, SEG_SS_100_C, SEG_SS_100_D,
45 | SEG_SS_100_E, SEG_SS_100_F, SEG_SS_100_G},
46 | {SEG_SS_10_A, SEG_SS_10_B, SEG_SS_10_C, SEG_SS_10_D,
47 | SEG_SS_10_E, SEG_SS_10_F, SEG_SS_10_G},
48 | {SEG_SS_1_A, SEG_SS_1_B, SEG_SS_1_C, SEG_SS_1_D,
49 | SEG_SS_1_E, SEG_SS_1_F, SEG_SS_1_G},
50 |
51 | {SEG_MS_10000_A, SEG_MS_10000_B, SEG_MS_10000_C, SEG_MS_10000_D,
52 | SEG_MS_10000_E, SEG_MS_10000_F, SEG_MS_10000_G},
53 | {SEG_MS_1000_A, SEG_MS_1000_B, SEG_MS_1000_C, SEG_MS_1000_D,
54 | SEG_MS_1000_E, SEG_MS_1000_F, SEG_MS_1000_G},
55 | {SEG_MS_100_A, SEG_MS_100_B, SEG_MS_100_C, SEG_MS_100_D,
56 | SEG_MS_100_E, SEG_MS_100_F, SEG_MS_100_G},
57 | {SEG_MS_10_A, SEG_MS_10_B, SEG_MS_10_C, SEG_MS_10_D,
58 | SEG_MS_10_E, SEG_MS_10_F, SEG_MS_10_G},
59 | {SEG_MS_1_A, SEG_MS_1_B, SEG_MS_1_C, SEG_MS_1_D,
60 | SEG_MS_1_E, SEG_MS_1_F, SEG_MS_1_G}
61 | };
62 |
63 | // table to map reading units to lcd segments
64 | // 0 = subscreen, 1 = main screen
65 | // order follows that defined in reading.h
66 | const uint8_t lcd_unit_icons[2][11] = {
67 | // on subscreen
68 | {
69 | SEG_NONE, SEG_SS_AMPS, SEG_NONE, SEG_NONE,
70 | SEG_SS_HERTZ, SEG_SS_nS, SEG_SS_OHMS,
71 | SEG_SS_VOLTS, SEG_NONE, SEG_NONE,
72 | SEG_SS_dB
73 | },
74 | // and main screen
75 | {
76 | SEG_NONE, SEG_MS_AMPS, SEG_MS_DUTY_PERCENT, SEG_MS_FARADS,
77 | SEG_MS_HERTZ, SEG_MS_mSEC, SEG_MS_OHMS,
78 | SEG_MS_VOLTS, SEG_MS_DEG_C, SEG_MS_DEG_F,
79 | SEG_NONE
80 | }
81 | };
82 |
83 | // table to map exponents to their icons
84 | // starts at nano, ends at mega
85 | // 0 = subscreen, 1 = main screen
86 | const uint8_t lcd_exponent_icons[2][6] = {
87 | // subscreen
88 | {SEG_NONE, SEG_NONE, SEG_SS_MILLI, SEG_NONE, SEG_SS_KILO, SEG_NONE},
89 | // main screen
90 | {SEG_MS_NANO, SEG_MS_MICRO, SEG_MS_MILLI,
91 | SEG_NONE, SEG_MS_KILO, SEG_MS_MEGA}
92 | };
93 |
94 | // table to map exponents to decimal points
95 | // 0 = subscreen, 1 = main screen
96 | const uint8_t lcd_decimal_points[2][5] = {
97 | // subscreen
98 | {SEG_SS_POINT_d0000, SEG_SS_POINT_d000,
99 | SEG_SS_POINT_d00, SEG_SS_POINT_d0, SEG_NONE},
100 | // and main screen
101 | {SEG_MS_POINT_d0000, SEG_MS_POINT_d000,
102 | SEG_MS_POINT_d00, SEG_MS_POINT_d0, SEG_NONE}
103 | };
--------------------------------------------------------------------------------
/EEVBlog/88mph/hardware/lcd_tables.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef HARDWARE_LCD_TABLES_H
20 | #define HARDWARE_LCD_TABLES_H
21 |
22 | #include
23 |
24 | extern const uint8_t lcd_7seg_font[36];
25 | extern const uint8_t lcd_7seg_segments[10][7];
26 | extern const uint8_t lcd_unit_icons[2][11];
27 | extern const uint8_t lcd_exponent_icons[2][6];
28 | extern const uint8_t lcd_decimal_points[2][5];
29 |
30 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/measurement/meas_mode_basic.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #include
20 |
21 | #include "measurement/meas_mode_basic.h"
22 |
23 | #include "measurement/measurement.h"
24 | #include "measurement/meas_modes.h"
25 | #include "acquisition/acquisition.h"
26 | #include "acquisition/reading.h"
27 |
28 | void meas_mode_func_volts_dc(meas_event_t event, reading_t* reading) {
29 | // average over 8 acquisitions
30 | static int avg_buf = 0;
31 | static int acqs = 0;
32 |
33 | switch (event) {
34 | case MEAS_EVENT_START: {
35 | // clear the average buffer
36 | avg_buf = 0;
37 | acqs = 0;
38 | // switch the acquisition engine to the correct mode
39 | acq_set_mode(ACQ_MODE_VOLTS_DC, ACQ_MODE_VOLTS_DC_SUBMODE_5d0000);
40 | break;
41 | }
42 |
43 | case MEAS_EVENT_NEW_ACQ: {
44 | // accumulate it in the average
45 | avg_buf += reading->millicounts;
46 | acqs += 1;
47 | // every 8, pass it on to the system
48 | if (acqs == 8) {
49 | acqs = 0;
50 | // reuse the reading since all the other parameters are the same
51 | reading->millicounts = avg_buf/8;
52 | avg_buf = 0;
53 | meas_put_reading(reading);
54 | }
55 | break;
56 | }
57 |
58 | default: {
59 | // if we get stopped, we can rely on the next guy to
60 | // switch acquisition mode and stuff correctly
61 | break;
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/EEVBlog/88mph/measurement/meas_mode_basic.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef MEASUREMENT_MEAS_MODE_BASIC_H
20 | #define MEASUREMENT_MEAS_MODE_BASIC_H
21 |
22 | #include "measurement/meas_modes.h"
23 | #include "acquisition/reading.h"
24 |
25 | // this file defines the measurement mode funcs for the boring modes
26 | // volts, etc
27 |
28 | void meas_mode_func_volts_dc(meas_event_t event, reading_t* reading);
29 |
30 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/measurement/meas_modes.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | // pointers to the measurement mode functions
20 |
21 | #include "measurement/meas_modes.h"
22 |
23 | #include "measurement/measurement.h"
24 | #include "measurement/meas_mode_basic.h"
25 |
26 | const meas_mode_func meas_mode_funcs[2] = {
27 | // MEAS_MODE_OFF
28 | meas_mode_func_off,
29 | // MEAS_MODE_VOLTS_DC
30 | meas_mode_func_volts_dc
31 | };
--------------------------------------------------------------------------------
/EEVBlog/88mph/measurement/meas_modes.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef MEASUREMENT_MEAS_MODES_H
20 | #define MEASUREMENT_MEAS_MODES_H
21 |
22 | #include
23 |
24 | #include "acquisition/reading.h"
25 |
26 | // this file defines the measurement modes
27 | // the corresponding .c has a table with function pointers to the mode handlers
28 | // keep the ordering of these options the same!
29 |
30 | typedef enum {
31 | MEAS_MODE_OFF=0,
32 | MEAS_MODE_VOLTS_DC
33 | } meas_mode_t;
34 |
35 | // we also need to define the mode function
36 | // this function will not be re-entered
37 | typedef enum {
38 | // begin measuring, reading is null
39 | MEAS_EVENT_START=0,
40 | // end measuring, reading is null
41 | MEAS_EVENT_STOP,
42 | // the acquisition engine has a new reading
43 | MEAS_EVENT_NEW_ACQ
44 | } meas_event_t;
45 |
46 | typedef void (*meas_mode_func)(meas_event_t event, reading_t* reading);
47 |
48 | extern const meas_mode_func meas_mode_funcs[2];
49 |
50 |
51 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/measurement/measurement.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #include
20 | #include
21 |
22 | #include "measurement/measurement.h"
23 |
24 | #include "acquisition/acquisition.h"
25 | #include "measurement/meas_modes.h"
26 | #include "system/job.h"
27 |
28 | static meas_mode_func curr_meas_mode_func = 0;
29 |
30 | // turn on the measurement engine
31 | void meas_init(void) {
32 | // switch to the 'off' mode manually
33 | // cause there should be no previous mode func to call
34 | curr_meas_mode_func = meas_mode_funcs[MEAS_MODE_OFF];
35 | curr_meas_mode_func(MEAS_EVENT_START, NULL);
36 | }
37 |
38 | // turn off the measurement engine
39 | void meas_deinit(void) {
40 | // stop the current measurement by switching to 'off'
41 | meas_set_mode(MEAS_MODE_OFF);
42 | // and cancel out the meas function
43 | curr_meas_mode_func = 0;
44 | job_disable(JOB_MEASUREMENT);
45 | }
46 |
47 | // do the measurement job
48 | void meas_handle_job_measurement(void) {
49 | // our job is to handle all the acquisitions
50 | reading_t reading;
51 |
52 | while (acq_get_reading(&reading)) {
53 | // tell the new reading to the mode function
54 | curr_meas_mode_func(MEAS_EVENT_NEW_ACQ, &reading);
55 | }
56 | }
57 |
58 | // set the measurement mode
59 | void meas_set_mode(meas_mode_t mode) {
60 | // stop measurement job from catching us in a weird spot
61 | bool meas_enabled = job_disable(JOB_MEASUREMENT);
62 | // turn off the current mode
63 | curr_meas_mode_func(MEAS_EVENT_STOP, NULL);
64 | // figure out which mode func goes with this mode
65 | curr_meas_mode_func = meas_mode_funcs[mode];
66 | // and start it up
67 | curr_meas_mode_func(MEAS_EVENT_START, NULL);
68 | // let the measurement job do its thing
69 | job_resume(JOB_MEASUREMENT, meas_enabled);
70 | }
71 |
72 | // must be power of 2!!
73 | #define MEAS_READING_QUEUE_SIZE (32)
74 |
75 | #define Q_MASK (MEAS_READING_QUEUE_SIZE-1)
76 |
77 | static volatile reading_t queue[MEAS_READING_QUEUE_SIZE];
78 | static volatile int q_head = 0;
79 | static volatile int q_tail = 0;
80 |
81 | // put a reading into the queue. if there is no space it's just dropped
82 | void meas_put_reading(reading_t* reading) {
83 | // can be called from any job, so protect ourselves!
84 | __disable_irq();
85 | // buffer head cause it's volatile
86 | // but we know we can't get interrupted
87 | int q_h = q_head;
88 | if (((q_h+1)&Q_MASK) != q_tail) {
89 | // we have space
90 | queue[q_h] = *reading;
91 | q_head = (q_h+1) & Q_MASK;
92 | }
93 | __enable_irq();
94 |
95 | // the system job is certainly interested in this new measurement
96 | job_schedule(JOB_SYSTEM);
97 | }
98 |
99 | // get a reading from the queue. returns false if there is no reading to get.
100 | // else puts the reading into reading and returns true
101 | bool meas_get_reading(reading_t* reading) {
102 | // can be called from any job, so protect ourselves!
103 | __disable_irq();
104 | // buffer tail cause it's volatile
105 | // but we know we can't get interrupted
106 | int q_t = q_tail;
107 | bool there_is_a_reading = (q_head != q_t);
108 | if (there_is_a_reading) {
109 | *reading = queue[q_t];
110 | q_tail = (q_t+1) & Q_MASK;
111 | }
112 | __enable_irq();
113 | return there_is_a_reading;
114 | }
115 |
116 | // empty the queue of all readings
117 | void meas_clear_readings(void) {
118 | // can be called from any job, so protect ourselves!
119 | __disable_irq();
120 | q_head = 0;
121 | q_tail = 0;
122 | __enable_irq();
123 | }
124 |
125 | void meas_mode_func_off(meas_event_t event, reading_t* reading) {
126 | if (event == MEAS_EVENT_START) {
127 | // make sure the acquisition engine is turned off if we're not
128 | // measuring anything
129 | acq_set_mode(ACQ_MODE_MISC, ACQ_MODE_MISC_SUBMODE_OFF);
130 | }
131 | }
--------------------------------------------------------------------------------
/EEVBlog/88mph/measurement/measurement.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef MEASUREMENT_MEASUREMENT_H
20 | #define MEASUREMENT_MEASUREMENT_H
21 |
22 | #include
23 | #include
24 |
25 | #include "measurement/meas_modes.h"
26 | #include "acquisition/reading.h"
27 |
28 | // turn on the measurement engine
29 | void meas_init(void);
30 | // turn off the measurement engine
31 | void meas_deinit(void);
32 |
33 | // do the measurement job
34 | void meas_handle_job_measurement(void);
35 |
36 | // set the measurement mode
37 | void meas_set_mode(meas_mode_t mode);
38 |
39 | // there is a queue of measured values, effectively between the measurement
40 | // job and the system job
41 | // put a reading into the queue. if there is no space it's just dropped
42 | void meas_put_reading(reading_t* reading);
43 | // get a reading from the queue. returns false if there is no reading to get.
44 | // else puts the reading into reading and returns true
45 | bool meas_get_reading(reading_t* reading);
46 | // empty the queue of all readings
47 | void meas_clear_readings(void);
48 |
49 | void meas_mode_func_off(meas_event_t event, reading_t* reading);
50 |
51 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/system/job.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #include
20 | #include
21 | #include "stm32l1xx.h"
22 |
23 | #include "system/job.h"
24 |
25 | void job_init(void) {
26 | // first, disable all the jobs
27 | job_deinit();
28 |
29 | // now configure the job priorities
30 | __disable_irq();
31 | // priority numbers go from 0 to 15, and 0 is the most important
32 | // the 1ms SYSTICK timer is the most important, because we want accurate
33 | // timing and it doesn't do much
34 | NVIC_SetPriority(SysTick_IRQn, 0);
35 |
36 | // next we want the 10ms timer. it's pretty fast and doesn't do much
37 | // it's handled by TIM6
38 | NVIC_SetPriority(JOB_10MS_TIMER, 1);
39 |
40 | // after the timers, handling acquisition is the most important
41 | NVIC_SetPriority(JOB_ACQUISITION, 5);
42 | // measurement is closely related to acquisition
43 | NVIC_SetPriority(JOB_MEASUREMENT, 7);
44 |
45 | // then the system job
46 | // it keeps the UI responsive
47 | NVIC_SetPriority(JOB_SYSTEM, 10);
48 |
49 | __enable_irq();
50 | }
51 |
52 | // disable all the jobs
53 | void job_deinit(void) {
54 | // disable job-specific IRQs
55 | // all at once, so things don't get weird
56 | __disable_irq();
57 | job_disable(JOB_SYSTEM);
58 | job_disable(JOB_10MS_TIMER);
59 | job_disable(JOB_MEASUREMENT);
60 | __enable_irq();
61 | }
62 |
63 | // enable a specific job, so it can run if it is scheduled
64 | // this un-schedules the job before enabling it
65 | void job_enable(job_t job) {
66 | // un-pend the IRQ to de-schedule
67 | NVIC_ClearPendingIRQ((IRQn_Type)job);
68 | // now enable it so it can run
69 | NVIC_EnableIRQ((IRQn_Type)job);
70 | }
71 |
72 | // resume a specific job by enabling it but not un-scheduling it
73 | // only resumes if resume is true. otherwise, does nothing
74 | void job_resume(job_t job, bool resume) {
75 | if (resume) {
76 | NVIC_EnableIRQ((IRQn_Type)job);
77 | }
78 | }
79 |
80 | // disable a specific job, so it won't run even if it is scheduled
81 | // returns whether or not the job was previously enabled
82 | // (to be used with resume)
83 | bool job_disable(job_t job) {
84 | __disable_irq();
85 | // this horrifying expression was mostly copied and pasted from CMSIS
86 | bool was_enabled =
87 | NVIC->ISER[(((uint32_t)(int32_t)job) >> 5UL)] &
88 | (uint32_t)(1UL << (((uint32_t)(int32_t)job) & 0x1FUL));
89 | NVIC_DisableIRQ((IRQn_Type)job);
90 | __enable_irq();
91 | return was_enabled;
92 | }
93 |
94 | // schedule a specific job, so it will run if it scheduled and no
95 | // higher priority job is running. this will only run the job once!
96 | void job_schedule(job_t job) {
97 | NVIC_SetPendingIRQ((IRQn_Type)job);
98 | }
99 |
100 | // catch the interrupts so we can direct them to their jobs
101 |
102 | // JOB_SYSTEM
103 | #include "system/system.h"
104 | void USB_HP_IRQHandler(void) {
105 | sys_handle_job_system();
106 | }
107 |
108 | // JOB_10MS_TIMER
109 | #include "system/timer.h"
110 | void TIM6_IRQHandler(void) {
111 | timer_handle_job_10ms_timer();
112 | }
113 |
114 | // JOB_MEASUREMENT
115 | #include "measurement/measurement.h"
116 | void USB_LP_IRQHandler(void) {
117 | meas_handle_job_measurement();
118 | }
--------------------------------------------------------------------------------
/EEVBlog/88mph/system/job.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef SYSTEM_JOB_H
20 | #define SYSTEM_JOB_H
21 |
22 | #include
23 | #include
24 | #include "stm32l1xx.h"
25 |
26 | // this module deals with Jobs
27 | // we attach specific jobs to interrupts we won't use, then use the NVIC
28 | // to automatically prioritize them
29 |
30 | // this module also sets priorities for all the interrupts we do use
31 |
32 | typedef enum {
33 | // this one must be enabled/disabled through hy_enable_irq
34 | // its handler is in hardware/hy3131.c
35 | JOB_ACQUISITION = EXTI3_IRQn,
36 | JOB_10MS_TIMER = TIM6_IRQn,
37 | JOB_SYSTEM = USB_HP_IRQn,
38 | JOB_MEASUREMENT = USB_LP_IRQn
39 | } job_t;
40 |
41 | // configure the NVIC for everything, but don't enable any of the jobs
42 | void job_init(void);
43 |
44 | // disable all the jobs
45 | void job_deinit(void);
46 |
47 | // enable a specific job, so it can run if it is scheduled
48 | // this un-schedules the job before enabling it
49 | void job_enable(job_t job);
50 |
51 | // resume a specific job by enabling it but not un-scheduling it
52 | // only resumes if resume is true. otherwise, does nothing
53 | void job_resume(job_t job, bool resume);
54 |
55 | // disable a specific job, so it won't run even if it is scheduled
56 | // returns whether or not the job was previously enabled
57 | // (to be used with resume)
58 | bool job_disable(job_t job);
59 |
60 | // schedule a specific job, so it will run if it scheduled and no
61 | // higher priority job is running. this will only run the job once!
62 | void job_schedule(job_t job);
63 |
64 |
65 | // catch the interrupts so we can direct them to their jobs
66 | // JOB_SYSTEM
67 | void USB_HP_IRQHandler(void);
68 |
69 | // JOB_10MS_TIMER
70 | void TIM6_IRQHandler(void);
71 |
72 | // JOB_MEASUREMENT
73 | void USB_LP_IRQHandler(void);
74 |
75 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/system/system.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #include
20 | #include
21 | #include "stm32l1xx.h"
22 |
23 | #include "system/system.h"
24 |
25 | #include "system/job.h"
26 | #include "system/timer.h"
27 | #include "hardware/lcd.h"
28 | #include "hardware/buttons.h"
29 | #include "measurement/measurement.h"
30 | #include "measurement/meas_modes.h"
31 | #include "acquisition/acquisition.h"
32 | #include "acquisition/reading.h"
33 |
34 | void sys_main_loop(void) {
35 | __enable_irq();
36 | job_init();
37 | acq_init();
38 | meas_init();
39 | timer_init();
40 |
41 | // enable all the jobs so the system starts working
42 | // do this with interrupts disabled so we can ensure we get
43 | // a chance to turn them all on!
44 | __disable_irq();
45 | job_enable(JOB_10MS_TIMER);
46 | job_enable(JOB_SYSTEM);
47 | job_enable(JOB_MEASUREMENT);
48 | job_enable(JOB_ACQUISITION);
49 | __enable_irq();
50 |
51 | meas_set_mode(MEAS_MODE_VOLTS_DC);
52 |
53 | while (1) {
54 | // the main loop just sleeps
55 | // we trust an interrupt will arrive and wake us up
56 | // if there is something interesting to do
57 | __WFI();
58 | }
59 | }
60 |
61 | void sys_handle_job_system(void) {
62 | // the system job basically does the UI
63 | // and routes around measurements
64 |
65 | static button_t curr_button = BTN_NONE;
66 | static button_t curr_state = BTN_RELEASED;
67 |
68 | reading_t reading;
69 | bool got_new_reading = false;
70 | // get the latest reading
71 | while (meas_get_reading(&reading)) {
72 | got_new_reading = true;
73 | }
74 |
75 | // and put it on the screen
76 | if (got_new_reading) {
77 | lcd_put_reading(LCD_SCREEN_MAIN, reading);
78 | lcd_queue_update();
79 | }
80 |
81 | button_state_t new_state;
82 | button_t new_button = btn_get_new(&new_state);
83 | if (new_button != BTN_NONE) {
84 | curr_button = new_button;
85 | curr_state = new_state;
86 | }
87 |
88 | reading_t r = {
89 | // millicounts
90 | (((int32_t)curr_button) * 1000)+
91 | (((int32_t)curr_state) * 100000)+
92 | (((int32_t)btn_get_rsw()) * 1000000),
93 | 0, // time_ms
94 | RDG_UNIT_NONE, // unit
95 | RDG_EXPONENT_NONE, // exponent
96 | RDG_DECIMAL_10000, // decimal
97 | RDG_KIND_MAIN // kind
98 | };
99 | lcd_put_reading(LCD_SCREEN_SUB, r);
100 | }
--------------------------------------------------------------------------------
/EEVBlog/88mph/system/system.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef SYSTEM_SYSTEM_H
20 | #define SYSTEM_SYSTEM_H
21 |
22 | // this file has the main loop and the timer handlers
23 |
24 | void sys_main_loop(void);
25 |
26 | void sys_handle_job_system(void);
27 |
28 | #endif
--------------------------------------------------------------------------------
/EEVBlog/88mph/system/timer.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #include
20 | #include
21 | #include "stm32l1xx.h"
22 |
23 | #include "system/timer.h"
24 |
25 | #include "system/job.h"
26 | #include "hardware/buttons.h"
27 | #include "hardware/lcd.h"
28 |
29 | // number of milliseconds since timer was inited
30 | volatile uint32_t timer_1ms_ticks = 0;
31 | // number of 10 millisecond periods since timer was inited
32 | volatile uint32_t timer_10ms_ticks = 0;
33 |
34 | static volatile bool timer_is_inited = false;
35 |
36 | void timer_init(void) {
37 | // 1ms timer is already set up by HAL
38 | // so just turn on the flag
39 | __disable_irq();
40 | timer_is_inited = true;
41 | // also zero out the tick counts
42 | timer_1ms_ticks = 0;
43 | timer_10ms_ticks = 0;
44 | __enable_irq();
45 |
46 | // set up TIM6 to interrupt at a 10ms interval
47 | // this happens every 120000 system clock cycles
48 |
49 | // power up timer and bring it out of reset
50 | __HAL_RCC_TIM6_FORCE_RESET();
51 | __HAL_RCC_TIM6_CLK_ENABLE();
52 | __HAL_RCC_TIM6_RELEASE_RESET();
53 |
54 | // we want 1 timer cycle per 64 clock cycles
55 | TIM6->PSC = 64-1;
56 |
57 | // automatically reload with 120000/64
58 | TIM6->ARR = 120000/64;
59 |
60 | TIM6->DIER = TIM_DIER_UIE; // enable interrupt on update
61 | TIM6->CR1 = TIM_CR1_URS | // only trigger update on overflow
62 | TIM_CR1_CEN; // turn on counting
63 |
64 | // the timer will be enabled when its job is enabled
65 | }
66 |
67 | void timer_deinit(void) {
68 | // 1ms timer must be kept running for HAL
69 | // so just turn off the flag
70 | __disable_irq();
71 | timer_is_inited = false;
72 | __enable_irq();
73 |
74 | // turn off the timer job
75 | job_disable(JOB_10MS_TIMER);
76 |
77 | // and turn off the timer hardware clock
78 | __HAL_RCC_TIM6_CLK_DISABLE();
79 | }
80 |
81 | // callback for 1ms timer
82 | // eventually this will just be the systick handler
83 | // but for now HAL needs it too and it stops us overriding
84 | // so we get called by HAL, with some performance penalty
85 | void HAL_SYSTICK_Callback(void) {
86 | // HAL needs to be running all the time or we will hang
87 | // so only do our work if we are inited
88 | if (!timer_is_inited) return;
89 | timer_1ms_ticks++;
90 | }
91 |
92 | void timer_handle_job_10ms_timer(void) {
93 | // acknowledge interrupt
94 | TIM6->SR = 0;
95 |
96 | timer_10ms_ticks++;
97 |
98 | btn_process();
99 |
100 | lcd_10ms_update_if_necessary();
101 | }
--------------------------------------------------------------------------------
/EEVBlog/88mph/system/timer.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * Copyright 2018 Thomas Watson *
3 | * *
4 | * This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/ *
5 | * *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); *
7 | * you may not use this file except in compliance with the License. *
8 | * You may obtain a copy of the License at *
9 | * *
10 | * http://www.apache.org/licenses/LICENSE-2.0 *
11 | * *
12 | * Unless required by applicable law or agreed to in writing, software *
13 | * distributed under the License is distributed on an "AS IS" BASIS, *
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 | * See the License for the specific language governing permissions and *
16 | * limitations under the License. *
17 | *****************************************************************************/
18 |
19 | #ifndef SYSTEM_TIMER_H
20 | #define SYSTEM_TIMER_H
21 |
22 | #include
23 |
24 | // this file handles the two system timers
25 | // 1ms and 10ms
26 |
27 | void timer_init(void);
28 | void timer_deinit(void);
29 |
30 | // callback for 1ms timer
31 | void HAL_SYSTICK_Callback(void);
32 | // callback for 10ms timer
33 | void timer_handle_job_10ms_timer(void);
34 |
35 | // number of milliseconds since timer was inited
36 | extern volatile uint32_t timer_1ms_ticks;
37 | // number of 10 millisecond periods since timer was inited
38 | extern volatile uint32_t timer_10ms_ticks;
39 |
40 | #endif
--------------------------------------------------------------------------------
/EEVBlog/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l152xd.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tpwrules/121gw-88mph/5b42a2438c7455c65d4678885089c44edbdbc351/EEVBlog/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l152xd.h
--------------------------------------------------------------------------------
/EEVBlog/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l1xx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tpwrules/121gw-88mph/5b42a2438c7455c65d4678885089c44edbdbc351/EEVBlog/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l1xx.h
--------------------------------------------------------------------------------
/EEVBlog/Drivers/CMSIS/Device/ST/STM32L1xx/Include/system_stm32l1xx.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32l1xx.h
4 | * @author MCD Application Team
5 | * @brief CMSIS Cortex-M3 Device System Source File for STM32L1xx devices.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © COPYRIGHT(c) 2017 STMicroelectronics
10 | *
11 | * Redistribution and use in source and binary forms, with or without modification,
12 | * are permitted provided that the following conditions are met:
13 | * 1. Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * 2. Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
19 | * may be used to endorse or promote products derived from this software
20 | * without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 | *
33 | ******************************************************************************
34 | */
35 |
36 | /** @addtogroup CMSIS
37 | * @{
38 | */
39 |
40 | /** @addtogroup stm32l1xx_system
41 | * @{
42 | */
43 |
44 | /**
45 | * @brief Define to prevent recursive inclusion
46 | */
47 | #ifndef __SYSTEM_STM32L1XX_H
48 | #define __SYSTEM_STM32L1XX_H
49 |
50 | #ifdef __cplusplus
51 | extern "C" {
52 | #endif
53 |
54 | /** @addtogroup STM32L1xx_System_Includes
55 | * @{
56 | */
57 |
58 | /**
59 | * @}
60 | */
61 |
62 |
63 | /** @addtogroup STM32L1xx_System_Exported_types
64 | * @{
65 | */
66 | /* This variable is updated in three ways:
67 | 1) by calling CMSIS function SystemCoreClockUpdate()
68 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq()
69 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
70 | Note: If you use this function to configure the system clock; then there
71 | is no need to call the 2 first functions listed above, since SystemCoreClock
72 | variable is updated automatically.
73 | */
74 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
75 | /*
76 | */
77 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */
78 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */
79 | extern const uint8_t PLLMulTable[9]; /*!< PLL multipiers table values */
80 |
81 | /**
82 | * @}
83 | */
84 |
85 | /** @addtogroup STM32L1xx_System_Exported_Constants
86 | * @{
87 | */
88 |
89 | /**
90 | * @}
91 | */
92 |
93 | /** @addtogroup STM32L1xx_System_Exported_Macros
94 | * @{
95 | */
96 |
97 | /**
98 | * @}
99 | */
100 |
101 | /** @addtogroup STM32L1xx_System_Exported_Functions
102 | * @{
103 | */
104 |
105 | extern void SystemInit(void);
106 | extern void SystemCoreClockUpdate(void);
107 | /**
108 | * @}
109 | */
110 |
111 | #ifdef __cplusplus
112 | }
113 | #endif
114 |
115 | #endif /*__SYSTEM_STM32L1XX_H */
116 |
117 | /**
118 | * @}
119 | */
120 |
121 | /**
122 | * @}
123 | */
124 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
125 |
--------------------------------------------------------------------------------
/EEVBlog/Drivers/CMSIS/Include/arm_common_tables.h:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------
2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
3 | *
4 | * $Date: 19. October 2015
5 | * $Revision: V.1.4.5 a
6 | *
7 | * Project: CMSIS DSP Library
8 | * Title: arm_common_tables.h
9 | *
10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions
11 | *
12 | * Target Processor: Cortex-M4/Cortex-M3
13 | *
14 | * Redistribution and use in source and binary forms, with or without
15 | * modification, are permitted provided that the following conditions
16 | * are met:
17 | * - Redistributions of source code must retain the above copyright
18 | * notice, this list of conditions and the following disclaimer.
19 | * - Redistributions in binary form must reproduce the above copyright
20 | * notice, this list of conditions and the following disclaimer in
21 | * the documentation and/or other materials provided with the
22 | * distribution.
23 | * - Neither the name of ARM LIMITED nor the names of its contributors
24 | * may be used to endorse or promote products derived from this
25 | * software without specific prior written permission.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 | * POSSIBILITY OF SUCH DAMAGE.
39 | * -------------------------------------------------------------------- */
40 |
41 | #ifndef _ARM_COMMON_TABLES_H
42 | #define _ARM_COMMON_TABLES_H
43 |
44 | #include "arm_math.h"
45 |
46 | extern const uint16_t armBitRevTable[1024];
47 | extern const q15_t armRecipTableQ15[64];
48 | extern const q31_t armRecipTableQ31[64];
49 | /* extern const q31_t realCoefAQ31[1024]; */
50 | /* extern const q31_t realCoefBQ31[1024]; */
51 | extern const float32_t twiddleCoef_16[32];
52 | extern const float32_t twiddleCoef_32[64];
53 | extern const float32_t twiddleCoef_64[128];
54 | extern const float32_t twiddleCoef_128[256];
55 | extern const float32_t twiddleCoef_256[512];
56 | extern const float32_t twiddleCoef_512[1024];
57 | extern const float32_t twiddleCoef_1024[2048];
58 | extern const float32_t twiddleCoef_2048[4096];
59 | extern const float32_t twiddleCoef_4096[8192];
60 | #define twiddleCoef twiddleCoef_4096
61 | extern const q31_t twiddleCoef_16_q31[24];
62 | extern const q31_t twiddleCoef_32_q31[48];
63 | extern const q31_t twiddleCoef_64_q31[96];
64 | extern const q31_t twiddleCoef_128_q31[192];
65 | extern const q31_t twiddleCoef_256_q31[384];
66 | extern const q31_t twiddleCoef_512_q31[768];
67 | extern const q31_t twiddleCoef_1024_q31[1536];
68 | extern const q31_t twiddleCoef_2048_q31[3072];
69 | extern const q31_t twiddleCoef_4096_q31[6144];
70 | extern const q15_t twiddleCoef_16_q15[24];
71 | extern const q15_t twiddleCoef_32_q15[48];
72 | extern const q15_t twiddleCoef_64_q15[96];
73 | extern const q15_t twiddleCoef_128_q15[192];
74 | extern const q15_t twiddleCoef_256_q15[384];
75 | extern const q15_t twiddleCoef_512_q15[768];
76 | extern const q15_t twiddleCoef_1024_q15[1536];
77 | extern const q15_t twiddleCoef_2048_q15[3072];
78 | extern const q15_t twiddleCoef_4096_q15[6144];
79 | extern const float32_t twiddleCoef_rfft_32[32];
80 | extern const float32_t twiddleCoef_rfft_64[64];
81 | extern const float32_t twiddleCoef_rfft_128[128];
82 | extern const float32_t twiddleCoef_rfft_256[256];
83 | extern const float32_t twiddleCoef_rfft_512[512];
84 | extern const float32_t twiddleCoef_rfft_1024[1024];
85 | extern const float32_t twiddleCoef_rfft_2048[2048];
86 | extern const float32_t twiddleCoef_rfft_4096[4096];
87 |
88 |
89 | /* floating-point bit reversal tables */
90 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 )
91 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 )
92 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 )
93 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 )
94 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 )
95 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 )
96 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800)
97 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808)
98 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032)
99 |
100 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH];
101 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH];
102 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH];
103 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH];
104 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH];
105 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH];
106 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH];
107 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH];
108 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH];
109 |
110 | /* fixed-point bit reversal tables */
111 | #define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 )
112 | #define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 )
113 | #define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 )
114 | #define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 )
115 | #define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 )
116 | #define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 )
117 | #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 )
118 | #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984)
119 | #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032)
120 |
121 | extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH];
122 | extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH];
123 | extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH];
124 | extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH];
125 | extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH];
126 | extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH];
127 | extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH];
128 | extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH];
129 | extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH];
130 |
131 | /* Tables for Fast Math Sine and Cosine */
132 | extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1];
133 | extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1];
134 | extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1];
135 |
136 | #endif /* ARM_COMMON_TABLES_H */
137 |
--------------------------------------------------------------------------------
/EEVBlog/Drivers/CMSIS/Include/arm_const_structs.h:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------
2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
3 | *
4 | * $Date: 19. March 2015
5 | * $Revision: V.1.4.5
6 | *
7 | * Project: CMSIS DSP Library
8 | * Title: arm_const_structs.h
9 | *
10 | * Description: This file has constant structs that are initialized for
11 | * user convenience. For example, some can be given as
12 | * arguments to the arm_cfft_f32() function.
13 | *
14 | * Target Processor: Cortex-M4/Cortex-M3
15 | *
16 | * Redistribution and use in source and binary forms, with or without
17 | * modification, are permitted provided that the following conditions
18 | * are met:
19 | * - Redistributions of source code must retain the above copyright
20 | * notice, this list of conditions and the following disclaimer.
21 | * - Redistributions in binary form must reproduce the above copyright
22 | * notice, this list of conditions and the following disclaimer in
23 | * the documentation and/or other materials provided with the
24 | * distribution.
25 | * - Neither the name of ARM LIMITED nor the names of its contributors
26 | * may be used to endorse or promote products derived from this
27 | * software without specific prior written permission.
28 | *
29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 | * POSSIBILITY OF SUCH DAMAGE.
41 | * -------------------------------------------------------------------- */
42 |
43 | #ifndef _ARM_CONST_STRUCTS_H
44 | #define _ARM_CONST_STRUCTS_H
45 |
46 | #include "arm_math.h"
47 | #include "arm_common_tables.h"
48 |
49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16;
50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32;
51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64;
52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128;
53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256;
54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512;
55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024;
56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048;
57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096;
58 |
59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16;
60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32;
61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64;
62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128;
63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256;
64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512;
65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024;
66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048;
67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096;
68 |
69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16;
70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32;
71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64;
72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128;
73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256;
74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512;
75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024;
76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048;
77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096;
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/EEVBlog/Drivers/CMSIS/Include/core_cmFunc.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file core_cmFunc.h
3 | * @brief CMSIS Cortex-M Core Function Access Header File
4 | * @version V4.30
5 | * @date 20. October 2015
6 | ******************************************************************************/
7 | /* Copyright (c) 2009 - 2015 ARM LIMITED
8 |
9 | All rights reserved.
10 | Redistribution and use in source and binary forms, with or without
11 | modification, are permitted provided that the following conditions are met:
12 | - Redistributions of source code must retain the above copyright
13 | notice, this list of conditions and the following disclaimer.
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 | - Neither the name of ARM nor the names of its contributors may be used
18 | to endorse or promote products derived from this software without
19 | specific prior written permission.
20 | *
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | POSSIBILITY OF SUCH DAMAGE.
32 | ---------------------------------------------------------------------------*/
33 |
34 |
35 | #if defined ( __ICCARM__ )
36 | #pragma system_include /* treat file as system include file for MISRA check */
37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38 | #pragma clang system_header /* treat file as system include file */
39 | #endif
40 |
41 | #ifndef __CORE_CMFUNC_H
42 | #define __CORE_CMFUNC_H
43 |
44 |
45 | /* ########################### Core Function Access ########################### */
46 | /** \ingroup CMSIS_Core_FunctionInterface
47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
48 | @{
49 | */
50 |
51 | /*------------------ RealView Compiler -----------------*/
52 | #if defined ( __CC_ARM )
53 | #include "cmsis_armcc.h"
54 |
55 | /*------------------ ARM Compiler V6 -------------------*/
56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
57 | #include "cmsis_armcc_V6.h"
58 |
59 | /*------------------ GNU Compiler ----------------------*/
60 | #elif defined ( __GNUC__ )
61 | #include "cmsis_gcc.h"
62 |
63 | /*------------------ ICC Compiler ----------------------*/
64 | #elif defined ( __ICCARM__ )
65 | #include
66 |
67 | /*------------------ TI CCS Compiler -------------------*/
68 | #elif defined ( __TMS470__ )
69 | #include
70 |
71 | /*------------------ TASKING Compiler ------------------*/
72 | #elif defined ( __TASKING__ )
73 | /*
74 | * The CMSIS functions have been implemented as intrinsics in the compiler.
75 | * Please use "carm -?i" to get an up to date list of all intrinsics,
76 | * Including the CMSIS ones.
77 | */
78 |
79 | /*------------------ COSMIC Compiler -------------------*/
80 | #elif defined ( __CSMC__ )
81 | #include
82 |
83 | #endif
84 |
85 | /*@} end of CMSIS_Core_RegAccFunctions */
86 |
87 | #endif /* __CORE_CMFUNC_H */
88 |
--------------------------------------------------------------------------------
/EEVBlog/Drivers/CMSIS/Include/core_cmInstr.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file core_cmInstr.h
3 | * @brief CMSIS Cortex-M Core Instruction Access Header File
4 | * @version V4.30
5 | * @date 20. October 2015
6 | ******************************************************************************/
7 | /* Copyright (c) 2009 - 2015 ARM LIMITED
8 |
9 | All rights reserved.
10 | Redistribution and use in source and binary forms, with or without
11 | modification, are permitted provided that the following conditions are met:
12 | - Redistributions of source code must retain the above copyright
13 | notice, this list of conditions and the following disclaimer.
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 | - Neither the name of ARM nor the names of its contributors may be used
18 | to endorse or promote products derived from this software without
19 | specific prior written permission.
20 | *
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | POSSIBILITY OF SUCH DAMAGE.
32 | ---------------------------------------------------------------------------*/
33 |
34 |
35 | #if defined ( __ICCARM__ )
36 | #pragma system_include /* treat file as system include file for MISRA check */
37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38 | #pragma clang system_header /* treat file as system include file */
39 | #endif
40 |
41 | #ifndef __CORE_CMINSTR_H
42 | #define __CORE_CMINSTR_H
43 |
44 |
45 | /* ########################## Core Instruction Access ######################### */
46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
47 | Access to dedicated instructions
48 | @{
49 | */
50 |
51 | /*------------------ RealView Compiler -----------------*/
52 | #if defined ( __CC_ARM )
53 | #include "cmsis_armcc.h"
54 |
55 | /*------------------ ARM Compiler V6 -------------------*/
56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
57 | #include "cmsis_armcc_V6.h"
58 |
59 | /*------------------ GNU Compiler ----------------------*/
60 | #elif defined ( __GNUC__ )
61 | #include "cmsis_gcc.h"
62 |
63 | /*------------------ ICC Compiler ----------------------*/
64 | #elif defined ( __ICCARM__ )
65 | #include
66 |
67 | /*------------------ TI CCS Compiler -------------------*/
68 | #elif defined ( __TMS470__ )
69 | #include
70 |
71 | /*------------------ TASKING Compiler ------------------*/
72 | #elif defined ( __TASKING__ )
73 | /*
74 | * The CMSIS functions have been implemented as intrinsics in the compiler.
75 | * Please use "carm -?i" to get an up to date list of all intrinsics,
76 | * Including the CMSIS ones.
77 | */
78 |
79 | /*------------------ COSMIC Compiler -------------------*/
80 | #elif defined ( __CSMC__ )
81 | #include
82 |
83 | #endif
84 |
85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
86 |
87 | #endif /* __CORE_CMINSTR_H */
88 |
--------------------------------------------------------------------------------
/EEVBlog/Drivers/CMSIS/Include/core_cmSimd.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file core_cmSimd.h
3 | * @brief CMSIS Cortex-M SIMD Header File
4 | * @version V4.30
5 | * @date 20. October 2015
6 | ******************************************************************************/
7 | /* Copyright (c) 2009 - 2015 ARM LIMITED
8 |
9 | All rights reserved.
10 | Redistribution and use in source and binary forms, with or without
11 | modification, are permitted provided that the following conditions are met:
12 | - Redistributions of source code must retain the above copyright
13 | notice, this list of conditions and the following disclaimer.
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 | - Neither the name of ARM nor the names of its contributors may be used
18 | to endorse or promote products derived from this software without
19 | specific prior written permission.
20 | *
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | POSSIBILITY OF SUCH DAMAGE.
32 | ---------------------------------------------------------------------------*/
33 |
34 |
35 | #if defined ( __ICCARM__ )
36 | #pragma system_include /* treat file as system include file for MISRA check */
37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38 | #pragma clang system_header /* treat file as system include file */
39 | #endif
40 |
41 | #ifndef __CORE_CMSIMD_H
42 | #define __CORE_CMSIMD_H
43 |
44 | #ifdef __cplusplus
45 | extern "C" {
46 | #endif
47 |
48 |
49 | /* ################### Compiler specific Intrinsics ########################### */
50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
51 | Access to dedicated SIMD instructions
52 | @{
53 | */
54 |
55 | /*------------------ RealView Compiler -----------------*/
56 | #if defined ( __CC_ARM )
57 | #include "cmsis_armcc.h"
58 |
59 | /*------------------ ARM Compiler V6 -------------------*/
60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
61 | #include "cmsis_armcc_V6.h"
62 |
63 | /*------------------ GNU Compiler ----------------------*/
64 | #elif defined ( __GNUC__ )
65 | #include "cmsis_gcc.h"
66 |
67 | /*------------------ ICC Compiler ----------------------*/
68 | #elif defined ( __ICCARM__ )
69 | #include
70 |
71 | /*------------------ TI CCS Compiler -------------------*/
72 | #elif defined ( __TMS470__ )
73 | #include
74 |
75 | /*------------------ TASKING Compiler ------------------*/
76 | #elif defined ( __TASKING__ )
77 | /*
78 | * The CMSIS functions have been implemented as intrinsics in the compiler.
79 | * Please use "carm -?i" to get an up to date list of all intrinsics,
80 | * Including the CMSIS ones.
81 | */
82 |
83 | /*------------------ COSMIC Compiler -------------------*/
84 | #elif defined ( __CSMC__ )
85 | #include
86 |
87 | #endif
88 |
89 | /*@} end of group CMSIS_SIMD_intrinsics */
90 |
91 |
92 | #ifdef __cplusplus
93 | }
94 | #endif
95 |
96 | #endif /* __CORE_CMSIMD_H */
97 |
--------------------------------------------------------------------------------
/EEVBlog/Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_flash_ramfunc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32l1xx_hal_flash_ramfunc.h
4 | * @author MCD Application Team
5 | * @brief Header file of FLASH RAMFUNC driver.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © COPYRIGHT(c) 2017 STMicroelectronics
10 | *
11 | * Redistribution and use in source and binary forms, with or without modification,
12 | * are permitted provided that the following conditions are met:
13 | * 1. Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * 2. Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
19 | * may be used to endorse or promote products derived from this software
20 | * without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 | *
33 | ******************************************************************************
34 | */
35 |
36 | /* Define to prevent recursive inclusion -------------------------------------*/
37 | #ifndef __STM32L1xx_FLASH_RAMFUNC_H
38 | #define __STM32L1xx_FLASH_RAMFUNC_H
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | /* Includes ------------------------------------------------------------------*/
45 | #include "stm32l1xx_hal_def.h"
46 |
47 | /** @addtogroup STM32L1xx_HAL_Driver
48 | * @{
49 | */
50 |
51 | /** @addtogroup FLASH_RAMFUNC
52 | * @{
53 | */
54 |
55 | /* Exported types ------------------------------------------------------------*/
56 |
57 |
58 | /* Exported functions --------------------------------------------------------*/
59 |
60 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions
61 | * @{
62 | */
63 |
64 | /*
65 | * @brief FLASH memory functions that should be executed from internal SRAM.
66 | * These functions are defined inside the "stm32l1xx_hal_flash_ramfunc.c"
67 | * file.
68 | */
69 |
70 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1
71 | * @{
72 | */
73 |
74 | __RAM_FUNC HAL_FLASHEx_EnableRunPowerDown(void);
75 | __RAM_FUNC HAL_FLASHEx_DisableRunPowerDown(void);
76 |
77 | /**
78 | * @}
79 | */
80 |
81 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group2
82 | * @{
83 | */
84 |
85 | #if defined(FLASH_PECR_PARALLBANK)
86 |
87 | __RAM_FUNC HAL_FLASHEx_EraseParallelPage(uint32_t Page_Address1, uint32_t Page_Address2);
88 | __RAM_FUNC HAL_FLASHEx_ProgramParallelHalfPage(uint32_t Address1, uint32_t* pBuffer1, uint32_t Address2, uint32_t* pBuffer2);
89 |
90 | #endif /* FLASH_PECR_PARALLBANK */
91 |
92 | __RAM_FUNC HAL_FLASHEx_HalfPageProgram(uint32_t Address, uint32_t* pBuffer);
93 |
94 | /**
95 | * @}
96 | */
97 |
98 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group3
99 | * @{
100 | */
101 | __RAM_FUNC HAL_FLASHEx_GetError(uint32_t *Error);
102 | /**
103 | * @}
104 | */
105 |
106 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group4
107 | * @{
108 | */
109 |
110 | __RAM_FUNC HAL_FLASHEx_DATAEEPROM_EraseDoubleWord(uint32_t Address);
111 | __RAM_FUNC HAL_FLASHEx_DATAEEPROM_ProgramDoubleWord(uint32_t Address, uint64_t Data);
112 |
113 | /**
114 | * @}
115 | */
116 |
117 | /**
118 | * @}
119 | */
120 |
121 | /**
122 | * @}
123 | */
124 |
125 | /**
126 | * @}
127 | */
128 |
129 | #ifdef __cplusplus
130 | }
131 | #endif
132 |
133 | #endif /* __STM32L1xx_FLASH_RAMFUNC_H */
134 |
135 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
136 |
--------------------------------------------------------------------------------
/EEVBlog/Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_pwr_ex.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32l1xx_hal_pwr_ex.h
4 | * @author MCD Application Team
5 | * @brief Header file of PWR HAL Extension module.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © COPYRIGHT(c) 2017 STMicroelectronics
10 | *
11 | * Redistribution and use in source and binary forms, with or without modification,
12 | * are permitted provided that the following conditions are met:
13 | * 1. Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * 2. Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
19 | * may be used to endorse or promote products derived from this software
20 | * without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 | *
33 | ******************************************************************************
34 | */
35 |
36 | /* Define to prevent recursive inclusion -------------------------------------*/
37 | #ifndef __STM32L1xx_HAL_PWR_EX_H
38 | #define __STM32L1xx_HAL_PWR_EX_H
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | /* Includes ------------------------------------------------------------------*/
45 | #include "stm32l1xx_hal_def.h"
46 |
47 | /** @addtogroup STM32L1xx_HAL_Driver
48 | * @{
49 | */
50 |
51 | /** @addtogroup PWREx
52 | * @{
53 | */
54 |
55 |
56 | /* Exported types ------------------------------------------------------------*/
57 | /* Exported constants --------------------------------------------------------*/
58 |
59 | /** @defgroup PWREx_Exported_Constants PWREx Exported Constants
60 | * @{
61 | */
62 |
63 |
64 | /** @defgroup PWREx_WakeUp_Pins PWREx Wakeup Pins
65 | * @{
66 | */
67 |
68 | #if defined (STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L151xE) || defined (STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) || defined (STM32L151xB) || defined (STM32L151xBA) || defined (STM32L151xC) || defined (STM32L152xB) || defined (STM32L152xBA) || defined (STM32L152xC) || defined (STM32L162xC)
69 |
70 | #define PWR_WAKEUP_PIN1 PWR_CSR_EWUP1
71 | #define PWR_WAKEUP_PIN2 PWR_CSR_EWUP2
72 | #define PWR_WAKEUP_PIN3 PWR_CSR_EWUP3
73 | #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
74 | ((PIN) == PWR_WAKEUP_PIN2) || \
75 | ((PIN) == PWR_WAKEUP_PIN3))
76 | #else
77 | #define PWR_WAKEUP_PIN1 PWR_CSR_EWUP1
78 | #define PWR_WAKEUP_PIN2 PWR_CSR_EWUP2
79 | #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
80 | ((PIN) == PWR_WAKEUP_PIN2))
81 | #endif
82 |
83 | /**
84 | * @}
85 | */
86 |
87 | /**
88 | * @}
89 | */
90 |
91 | /* Exported macro ------------------------------------------------------------*/
92 | /* Exported functions --------------------------------------------------------*/
93 |
94 | /** @defgroup PWREx_Exported_Functions PWREx Exported Functions
95 | * @{
96 | */
97 |
98 | /** @addtogroup PWREx_Exported_Functions_Group1
99 | * @{
100 | */
101 |
102 | /* Peripheral Control methods ************************************************/
103 | uint32_t HAL_PWREx_GetVoltageRange(void);
104 | void HAL_PWREx_EnableFastWakeUp(void);
105 | void HAL_PWREx_DisableFastWakeUp(void);
106 | void HAL_PWREx_EnableUltraLowPower(void);
107 | void HAL_PWREx_DisableUltraLowPower(void);
108 | void HAL_PWREx_EnableLowPowerRunMode(void);
109 | HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void);
110 |
111 | /**
112 | * @}
113 | */
114 |
115 | /**
116 | * @}
117 | */
118 |
119 | /**
120 | * @}
121 | */
122 |
123 | /**
124 | * @}
125 | */
126 |
127 | #ifdef __cplusplus
128 | }
129 | #endif
130 |
131 |
132 | #endif /* __STM32L1xx_HAL_PWR_EX_H */
133 |
134 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
135 |
--------------------------------------------------------------------------------
/EEVBlog/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_pwr_ex.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32l1xx_hal_pwr_ex.c
4 | * @author MCD Application Team
5 | * @brief Extended PWR HAL module driver.
6 | * This file provides firmware functions to manage the following
7 | * functionalities of the Power Controller (PWR) peripheral:
8 | * + Extended Initialization and de-initialization functions
9 | * + Extended Peripheral Control functions
10 | *
11 | ******************************************************************************
12 | * @attention
13 | *
14 | * © COPYRIGHT(c) 2017 STMicroelectronics
15 | *
16 | * Redistribution and use in source and binary forms, with or without modification,
17 | * are permitted provided that the following conditions are met:
18 | * 1. Redistributions of source code must retain the above copyright notice,
19 | * this list of conditions and the following disclaimer.
20 | * 2. Redistributions in binary form must reproduce the above copyright notice,
21 | * this list of conditions and the following disclaimer in the documentation
22 | * and/or other materials provided with the distribution.
23 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
24 | * may be used to endorse or promote products derived from this software
25 | * without specific prior written permission.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 | *
38 | ******************************************************************************
39 | */
40 |
41 | /* Includes ------------------------------------------------------------------*/
42 | #include "stm32l1xx_hal.h"
43 |
44 | /** @addtogroup STM32L1xx_HAL_Driver
45 | * @{
46 | */
47 |
48 | /** @defgroup PWREx PWREx
49 | * @brief PWR HAL module driver
50 | * @{
51 | */
52 |
53 | #ifdef HAL_PWR_MODULE_ENABLED
54 |
55 | /* Private typedef -----------------------------------------------------------*/
56 | /* Private define ------------------------------------------------------------*/
57 | /* Private macro -------------------------------------------------------------*/
58 | /* Private variables ---------------------------------------------------------*/
59 | /* Private function prototypes -----------------------------------------------*/
60 | /* Private functions ---------------------------------------------------------*/
61 |
62 | /** @defgroup PWREx_Exported_Functions PWREx Exported Functions
63 | * @{
64 | */
65 |
66 | /** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Features Functions
67 | * @brief Low Power modes configuration functions
68 | *
69 | @verbatim
70 |
71 | ===============================================================================
72 | ##### Peripheral extended features functions #####
73 | ===============================================================================
74 | @endverbatim
75 | * @{
76 | */
77 |
78 | /**
79 | * @brief Return Voltage Scaling Range.
80 | * @retval VOS bit field (PWR_REGULATOR_VOLTAGE_SCALE1, PWR_REGULATOR_VOLTAGE_SCALE2 or PWR_REGULATOR_VOLTAGE_SCALE3)
81 | */
82 | uint32_t HAL_PWREx_GetVoltageRange(void)
83 | {
84 | return (PWR->CR & PWR_CR_VOS);
85 | }
86 |
87 |
88 | /**
89 | * @brief Enables the Fast WakeUp from Ultra Low Power mode.
90 | * @note This bit works in conjunction with ULP bit.
91 | * Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when
92 | * exiting from low power mode.
93 | * @retval None
94 | */
95 | void HAL_PWREx_EnableFastWakeUp(void)
96 | {
97 | /* Enable the fast wake up */
98 | *(__IO uint32_t *) CR_FWU_BB = (uint32_t)ENABLE;
99 | }
100 |
101 | /**
102 | * @brief Disables the Fast WakeUp from Ultra Low Power mode.
103 | * @retval None
104 | */
105 | void HAL_PWREx_DisableFastWakeUp(void)
106 | {
107 | /* Disable the fast wake up */
108 | *(__IO uint32_t *) CR_FWU_BB = (uint32_t)DISABLE;
109 | }
110 |
111 | /**
112 | * @brief Enables the Ultra Low Power mode
113 | * @retval None
114 | */
115 | void HAL_PWREx_EnableUltraLowPower(void)
116 | {
117 | /* Enable the Ultra Low Power mode */
118 | *(__IO uint32_t *) CR_ULP_BB = (uint32_t)ENABLE;
119 | }
120 |
121 | /**
122 | * @brief Disables the Ultra Low Power mode
123 | * @retval None
124 | */
125 | void HAL_PWREx_DisableUltraLowPower(void)
126 | {
127 | /* Disable the Ultra Low Power mode */
128 | *(__IO uint32_t *) CR_ULP_BB = (uint32_t)DISABLE;
129 | }
130 |
131 | /**
132 | * @brief Enters the Low Power Run mode.
133 | * @note Low power run mode can only be entered when VCORE is in range 2.
134 | * In addition, the dynamic voltage scaling must not be used when Low
135 | * power run mode is selected. Only Stop and Sleep modes with regulator
136 | * configured in Low power mode is allowed when Low power run mode is
137 | * selected.
138 | * @note In Low power run mode, all I/O pins keep the same state as in Run mode.
139 | * @retval None
140 | */
141 | void HAL_PWREx_EnableLowPowerRunMode(void)
142 | {
143 | /* Enters the Low Power Run mode */
144 | *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)ENABLE;
145 | *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)ENABLE;
146 | }
147 |
148 | /**
149 | * @brief Exits the Low Power Run mode.
150 | * @retval None
151 | */
152 | HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void)
153 | {
154 | /* Exits the Low Power Run mode */
155 | *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)DISABLE;
156 | *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)DISABLE;
157 | return HAL_OK;
158 | }
159 |
160 | /**
161 | * @}
162 | */
163 |
164 | /**
165 | * @}
166 | */
167 |
168 | #endif /* HAL_PWR_MODULE_ENABLED */
169 | /**
170 | * @}
171 | */
172 |
173 | /**
174 | * @}
175 | */
176 |
177 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
178 |
--------------------------------------------------------------------------------
/EEVBlog/EEVBlog Debug.cfg:
--------------------------------------------------------------------------------
1 | # This is an EEVBlog board with a single STM32L152ZDTx chip
2 | #
3 | # Generated by System Workbench for STM32
4 | # Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s)
5 |
6 | source [find interface/stlink.cfg]
7 |
8 | set WORKAREASIZE 0x8000
9 |
10 | transport select "hla_swd"
11 |
12 | set CHIPNAME STM32L152ZDTx
13 | set BOARDNAME EEVBlog
14 |
15 | # Enable debug when in low power modes
16 | set ENABLE_LOW_POWER 1
17 |
18 | # Stop Watchdog counters when halt
19 | set STOP_WATCHDOG 1
20 |
21 | # STlink Debug clock frequency
22 | set CLOCK_FREQ 4000
23 |
24 | # use hardware reset, connect under reset
25 | # connect_assert_srst needed if low power mode application running (WFI...)
26 | reset_config srst_only srst_nogate connect_assert_srst
27 | set CONNECT_UNDER_RESET 1
28 |
29 | source [find target/stm32l1x.cfg]
30 |
--------------------------------------------------------------------------------
/EEVBlog/EEVBlog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | EEVBlog
5 | STM32L152ZDTx
6 | SWD
7 | ST-LinkV2-1
8 |
9 |
10 |
--------------------------------------------------------------------------------
/EEVBlog/Inc/bsp_driver_sd.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file bsp_driver_sd.h (based on stm32l152d_eval_sd.h)
4 | * @brief This file contains the common defines and functions prototypes for
5 | * the bsp_driver_sd.c driver.
6 | ******************************************************************************
7 | * This notice applies to any and all portions of this file
8 | * that are not between comment pairs USER CODE BEGIN and
9 | * USER CODE END. Other portions of this file, whether
10 | * inserted by the user or by software development tools
11 | * are owned by their respective copyright owners.
12 | *
13 | * Copyright (c) 2018 STMicroelectronics International N.V.
14 | * All rights reserved.
15 | *
16 | * Redistribution and use in source and binary forms, with or without
17 | * modification, are permitted, provided that the following conditions are met:
18 | *
19 | * 1. Redistribution of source code must retain the above copyright notice,
20 | * this list of conditions and the following disclaimer.
21 | * 2. Redistributions in binary form must reproduce the above copyright notice,
22 | * this list of conditions and the following disclaimer in the documentation
23 | * and/or other materials provided with the distribution.
24 | * 3. Neither the name of STMicroelectronics nor the names of other
25 | * contributors to this software may be used to endorse or promote products
26 | * derived from this software without specific written permission.
27 | * 4. This software, including modifications and/or derivative works of this
28 | * software, must execute solely and exclusively on microcontroller or
29 | * microprocessor devices manufactured by or for STMicroelectronics.
30 | * 5. Redistribution and use of this software other than as permitted under
31 | * this license is void and will automatically terminate your rights under
32 | * this license.
33 | *
34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 | *
47 | ******************************************************************************
48 | */
49 |
50 | /* Define to prevent recursive inclusion -------------------------------------*/
51 | #ifndef __STM32L1_SD_H
52 | #define __STM32L1_SD_H
53 |
54 | #ifdef __cplusplus
55 | extern "C" {
56 | #endif
57 |
58 | /* Includes ------------------------------------------------------------------*/
59 | #include "stm32l1xx_hal.h"
60 |
61 | /* Exported types --------------------------------------------------------*/
62 | /**
63 | * @brief SD Card information structure
64 | */
65 | #ifndef SD_CardInfo
66 | #define SD_CardInfo HAL_SD_CardInfoTypedef
67 | #endif
68 |
69 | /* Exported constants --------------------------------------------------------*/
70 | /**
71 | * @brief SD status structure definition
72 | */
73 | #define MSD_OK ((uint8_t)0x00)
74 | #define MSD_ERROR ((uint8_t)0x01)
75 |
76 | #define SD_PRESENT ((uint8_t)0x01)
77 | #define SD_NOT_PRESENT ((uint8_t)0x00)
78 | #define SD_DATATIMEOUT ((uint32_t)100000000)
79 |
80 | /* USER CODE BEGIN 0 */
81 | /* Exported functions --------------------------------------------------------*/
82 | uint8_t BSP_SD_Init(void);
83 | uint8_t BSP_SD_ITConfig(void);
84 | void BSP_SD_DetectIT(void);
85 | void BSP_SD_DetectCallback(void);
86 | uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
87 | uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
88 | uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
89 | uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
90 | uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr);
91 | void BSP_SD_IRQHandler(void);
92 | void BSP_SD_DMA_Tx_IRQHandler(void);
93 | void BSP_SD_DMA_Rx_IRQHandler(void);
94 | HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void);
95 | void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
96 | uint8_t BSP_SD_IsDetected(void);
97 | /* USER CODE END 0 */
98 |
99 | #ifdef __cplusplus
100 | }
101 | #endif
102 |
103 | #endif /* __STM32L1_SD_H */
104 |
105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
106 |
--------------------------------------------------------------------------------
/EEVBlog/Inc/fatfs.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file fatfs.h
4 | * @brief Header for fatfs applications
5 | ******************************************************************************
6 | * This notice applies to any and all portions of this file
7 | * that are not between comment pairs USER CODE BEGIN and
8 | * USER CODE END. Other portions of this file, whether
9 | * inserted by the user or by software development tools
10 | * are owned by their respective copyright owners.
11 | *
12 | * Copyright (c) 2018 STMicroelectronics International N.V.
13 | * All rights reserved.
14 | *
15 | * Redistribution and use in source and binary forms, with or without
16 | * modification, are permitted, provided that the following conditions are met:
17 | *
18 | * 1. Redistribution of source code must retain the above copyright notice,
19 | * this list of conditions and the following disclaimer.
20 | * 2. Redistributions in binary form must reproduce the above copyright notice,
21 | * this list of conditions and the following disclaimer in the documentation
22 | * and/or other materials provided with the distribution.
23 | * 3. Neither the name of STMicroelectronics nor the names of other
24 | * contributors to this software may be used to endorse or promote products
25 | * derived from this software without specific written permission.
26 | * 4. This software, including modifications and/or derivative works of this
27 | * software, must execute solely and exclusively on microcontroller or
28 | * microprocessor devices manufactured by or for STMicroelectronics.
29 | * 5. Redistribution and use of this software other than as permitted under
30 | * this license is void and will automatically terminate your rights under
31 | * this license.
32 | *
33 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
34 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
35 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
36 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
37 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
38 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
41 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
42 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
43 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
44 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 | *
46 | ******************************************************************************
47 | */
48 |
49 | /* Define to prevent recursive inclusion -------------------------------------*/
50 | #ifndef __fatfs_H
51 | #define __fatfs_H
52 | #ifdef __cplusplus
53 | extern "C" {
54 | #endif
55 |
56 | #include "ff.h"
57 | #include "ff_gen_drv.h"
58 | #include "sd_diskio.h" /* defines SD_Driver as external */
59 |
60 | /* USER CODE BEGIN Includes */
61 |
62 | /* USER CODE END Includes */
63 |
64 | extern uint8_t retSD; /* Return value for SD */
65 | extern char SDPath[4]; /* SD logical drive path */
66 | extern FATFS SDFatFS; /* File system object for SD logical drive */
67 | extern FIL SDFile; /* File object for SD */
68 |
69 | void MX_FATFS_Init(void);
70 |
71 | /* USER CODE BEGIN Prototypes */
72 |
73 | /* USER CODE END Prototypes */
74 | #ifdef __cplusplus
75 | }
76 | #endif
77 | #endif /*__fatfs_H */
78 |
79 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
80 |
--------------------------------------------------------------------------------
/EEVBlog/Inc/main.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file : main.h
4 | * @brief : Header for main.c file.
5 | * This file contains the common defines of the application.
6 | ******************************************************************************
7 | * This notice applies to any and all portions of this file
8 | * that are not between comment pairs USER CODE BEGIN and
9 | * USER CODE END. Other portions of this file, whether
10 | * inserted by the user or by software development tools
11 | * are owned by their respective copyright owners.
12 | *
13 | * Copyright (c) 2018 STMicroelectronics International N.V.
14 | * All rights reserved.
15 | *
16 | * Redistribution and use in source and binary forms, with or without
17 | * modification, are permitted, provided that the following conditions are met:
18 | *
19 | * 1. Redistribution of source code must retain the above copyright notice,
20 | * this list of conditions and the following disclaimer.
21 | * 2. Redistributions in binary form must reproduce the above copyright notice,
22 | * this list of conditions and the following disclaimer in the documentation
23 | * and/or other materials provided with the distribution.
24 | * 3. Neither the name of STMicroelectronics nor the names of other
25 | * contributors to this software may be used to endorse or promote products
26 | * derived from this software without specific written permission.
27 | * 4. This software, including modifications and/or derivative works of this
28 | * software, must execute solely and exclusively on microcontroller or
29 | * microprocessor devices manufactured by or for STMicroelectronics.
30 | * 5. Redistribution and use of this software other than as permitted under
31 | * this license is void and will automatically terminate your rights under
32 | * this license.
33 | *
34 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
35 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
36 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
37 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
38 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
39 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
40 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
42 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
45 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 | *
47 | ******************************************************************************
48 | */
49 |
50 | /* Define to prevent recursive inclusion -------------------------------------*/
51 | #ifndef __MAIN_H__
52 | #define __MAIN_H__
53 |
54 | /* Includes ------------------------------------------------------------------*/
55 |
56 | /* USER CODE BEGIN Includes */
57 |
58 | /* USER CODE END Includes */
59 |
60 | /* Private define ------------------------------------------------------------*/
61 |
62 | #define HW_AMP_CTL_Pin GPIO_PIN_5
63 | #define HW_AMP_CTL_GPIO_Port GPIOE
64 | #define RTC_CE_Pin GPIO_PIN_13
65 | #define RTC_CE_GPIO_Port GPIOC
66 | #define HY_CK_Pin GPIO_PIN_0
67 | #define HY_CK_GPIO_Port GPIOF
68 | #define HY_CS_Pin GPIO_PIN_1
69 | #define HY_CS_GPIO_Port GPIOF
70 | #define HY_DI_Pin GPIO_PIN_2
71 | #define HY_DI_GPIO_Port GPIOF
72 | #define HY_DO_Pin GPIO_PIN_3
73 | #define HY_DO_GPIO_Port GPIOF
74 | #define HW_CTL_D_Pin GPIO_PIN_4
75 | #define HW_CTL_D_GPIO_Port GPIOF
76 | #define HW_CTL_E_Pin GPIO_PIN_5
77 | #define HW_CTL_E_GPIO_Port GPIOF
78 | #define HW_ENB_Pin GPIO_PIN_6
79 | #define HW_ENB_GPIO_Port GPIOF
80 | #define HW_THERMISTOR_Pin GPIO_PIN_4
81 | #define HW_THERMISTOR_GPIO_Port GPIOA
82 | #define HW_LOW_BAT_Pin GPIO_PIN_5
83 | #define HW_LOW_BAT_GPIO_Port GPIOA
84 | #define SCH_UNCONNECTED_B_Pin GPIO_PIN_11
85 | #define SCH_UNCONNECTED_B_GPIO_Port GPIOF
86 | #define SCH_UNCONNECTED_C_Pin GPIO_PIN_13
87 | #define SCH_UNCONNECTED_C_GPIO_Port GPIOF
88 | #define SCH_UNCONNECTED_D_Pin GPIO_PIN_14
89 | #define SCH_UNCONNECTED_D_GPIO_Port GPIOF
90 | #define R_mA_A_Pin GPIO_PIN_0
91 | #define R_mA_A_GPIO_Port GPIOG
92 | #define R_uA_Pin GPIO_PIN_1
93 | #define R_uA_GPIO_Port GPIOG
94 | #define SYS_BUZZER_Pin GPIO_PIN_7
95 | #define SYS_BUZZER_GPIO_Port GPIOE
96 | #define SYS_BACKLIGHT_Pin GPIO_PIN_8
97 | #define SYS_BACKLIGHT_GPIO_Port GPIOE
98 | #define HW_PWR_CTL_Pin GPIO_PIN_9
99 | #define HW_PWR_CTL_GPIO_Port GPIOE
100 | #define B_FUSE_mA_Pin GPIO_PIN_10
101 | #define B_FUSE_mA_GPIO_Port GPIOE
102 | #define B_FUSE_A_Pin GPIO_PIN_11
103 | #define B_FUSE_A_GPIO_Port GPIOE
104 | #define HW_SHDN_A_Pin GPIO_PIN_12
105 | #define HW_SHDN_A_GPIO_Port GPIOE
106 | #define SCH_UNCONNECTED_A_Pin GPIO_PIN_13
107 | #define SCH_UNCONNECTED_A_GPIO_Port GPIOE
108 | #define HW_LED_CK_Pin GPIO_PIN_15
109 | #define HW_LED_CK_GPIO_Port GPIOE
110 | #define R_VA_Pin GPIO_PIN_2
111 | #define R_VA_GPIO_Port GPIOG
112 | #define R_O_B_D_C_Pin GPIO_PIN_3
113 | #define R_O_B_D_C_GPIO_Port GPIOG
114 | #define R_Hz_Duty_Pin GPIO_PIN_4
115 | #define R_Hz_Duty_GPIO_Port GPIOG
116 | #define R_mV_TEMP_Pin GPIO_PIN_5
117 | #define R_mV_TEMP_GPIO_Port GPIOG
118 | #define R_VOLTS_Pin GPIO_PIN_6
119 | #define R_VOLTS_GPIO_Port GPIOG
120 | #define R_LowZ_Pin GPIO_PIN_7
121 | #define R_LowZ_GPIO_Port GPIOG
122 | #define B_MODE_Pin GPIO_PIN_8
123 | #define B_MODE_GPIO_Port GPIOG
124 | #define HW_VA_CTL_Pin GPIO_PIN_11
125 | #define HW_VA_CTL_GPIO_Port GPIOA
126 | #define HW_FRE_CTL_Pin GPIO_PIN_12
127 | #define HW_FRE_CTL_GPIO_Port GPIOA
128 | #define HW_TEMP_CTL_Pin GPIO_PIN_2
129 | #define HW_TEMP_CTL_GPIO_Port GPIOH
130 | #define HW_CTL_B_Pin GPIO_PIN_11
131 | #define HW_CTL_B_GPIO_Port GPIOC
132 | #define HW_CTL_A_Pin GPIO_PIN_0
133 | #define HW_CTL_A_GPIO_Port GPIOD
134 | #define HW_PWR_CTL2_Pin GPIO_PIN_1
135 | #define HW_PWR_CTL2_GPIO_Port GPIOD
136 | #define HW_DCmV_CTL_Pin GPIO_PIN_7
137 | #define HW_DCmV_CTL_GPIO_Port GPIOD
138 | #define B_SETUP_Pin GPIO_PIN_9
139 | #define B_SETUP_GPIO_Port GPIOG
140 | #define B_MINMAX_Pin GPIO_PIN_10
141 | #define B_MINMAX_GPIO_Port GPIOG
142 | #define B_MEM_Pin GPIO_PIN_11
143 | #define B_MEM_GPIO_Port GPIOG
144 | #define B_RANGE_Pin GPIO_PIN_12
145 | #define B_RANGE_GPIO_Port GPIOG
146 | #define B_HOLD_Pin GPIO_PIN_13
147 | #define B_HOLD_GPIO_Port GPIOG
148 | #define B_REL_Pin GPIO_PIN_14
149 | #define B_REL_GPIO_Port GPIOG
150 | #define B_PEAK_Pin GPIO_PIN_15
151 | #define B_PEAK_GPIO_Port GPIOG
152 | #define RTC_CLK_Pin GPIO_PIN_6
153 | #define RTC_CLK_GPIO_Port GPIOB
154 | #define RTC_DO_Pin GPIO_PIN_7
155 | #define RTC_DO_GPIO_Port GPIOB
156 |
157 | /* ########################## Assert Selection ############################## */
158 | /**
159 | * @brief Uncomment the line below to expanse the "assert_param" macro in the
160 | * HAL drivers code
161 | */
162 | /* #define USE_FULL_ASSERT 1U */
163 |
164 | /* USER CODE BEGIN Private defines */
165 |
166 | /* USER CODE END Private defines */
167 |
168 | #ifdef __cplusplus
169 | extern "C" {
170 | #endif
171 | void _Error_Handler(char *, int);
172 |
173 | #define Error_Handler() _Error_Handler(__FILE__, __LINE__)
174 | #ifdef __cplusplus
175 | }
176 | #endif
177 |
178 | #endif /* __MAIN_H__ */
179 |
180 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
181 |
--------------------------------------------------------------------------------
/EEVBlog/Inc/stm32l1xx_it.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32l1xx_it.h
4 | * @brief This file contains the headers of the interrupt handlers.
5 | ******************************************************************************
6 | *
7 | * COPYRIGHT(c) 2018 STMicroelectronics
8 | *
9 | * Redistribution and use in source and binary forms, with or without modification,
10 | * are permitted provided that the following conditions are met:
11 | * 1. Redistributions of source code must retain the above copyright notice,
12 | * this list of conditions and the following disclaimer.
13 | * 2. Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
17 | * may be used to endorse or promote products derived from this software
18 | * without specific prior written permission.
19 | *
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *
31 | ******************************************************************************
32 | */
33 |
34 | /* Define to prevent recursive inclusion -------------------------------------*/
35 | #ifndef __STM32L1xx_IT_H
36 | #define __STM32L1xx_IT_H
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | /* Includes ------------------------------------------------------------------*/
43 | #include "stm32l1xx_hal.h"
44 | #include "main.h"
45 | /* Exported types ------------------------------------------------------------*/
46 | /* Exported constants --------------------------------------------------------*/
47 | /* Exported macro ------------------------------------------------------------*/
48 | /* Exported functions ------------------------------------------------------- */
49 |
50 | void NMI_Handler(void);
51 | void HardFault_Handler(void);
52 | void MemManage_Handler(void);
53 | void BusFault_Handler(void);
54 | void UsageFault_Handler(void);
55 | void SVC_Handler(void);
56 | void DebugMon_Handler(void);
57 | void PendSV_Handler(void);
58 | void SysTick_Handler(void);
59 | void DMA2_Channel4_IRQHandler(void);
60 |
61 | #ifdef __cplusplus
62 | }
63 | #endif
64 |
65 | #endif /* __STM32L1xx_IT_H */
66 |
67 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
68 |
--------------------------------------------------------------------------------
/EEVBlog/Middlewares/Third_Party/FatFs/src/diskio.c:
--------------------------------------------------------------------------------
1 | /*-----------------------------------------------------------------------*/
2 | /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */
3 | /* */
4 | /* Portions COPYRIGHT 2015 STMicroelectronics */
5 | /* Portions Copyright (C) 2014, ChaN, all right reserved */
6 | /*-----------------------------------------------------------------------*/
7 | /* If a working storage control module is available, it should be */
8 | /* attached to the FatFs via a glue function rather than modifying it. */
9 | /* This is an example of glue functions to attach various exsisting */
10 | /* storage control modules to the FatFs module with a defined API. */
11 | /*-----------------------------------------------------------------------*/
12 |
13 | /**
14 | ******************************************************************************
15 | * @file diskio.c
16 | * @author MCD Application Team
17 | * @version V1.3.0
18 | * @date 08-May-2015
19 | * @brief FatFs low level disk I/O module.
20 | ******************************************************************************
21 | * @attention
22 | *
23 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
24 | * You may not use this file except in compliance with the License.
25 | * You may obtain a copy of the License at:
26 | *
27 | * http://www.st.com/software_license_agreement_liberty_v2
28 | *
29 | * Unless required by applicable law or agreed to in writing, software
30 | * distributed under the License is distributed on an "AS IS" BASIS,
31 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 | * See the License for the specific language governing permissions and
33 | * limitations under the License.
34 | *
35 | ******************************************************************************
36 | */
37 |
38 | /* Includes ------------------------------------------------------------------*/
39 | #include "diskio.h"
40 | #include "ff_gen_drv.h"
41 |
42 | /* Private typedef -----------------------------------------------------------*/
43 | /* Private define ------------------------------------------------------------*/
44 | /* Private variables ---------------------------------------------------------*/
45 | extern Disk_drvTypeDef disk;
46 |
47 | /* Private function prototypes -----------------------------------------------*/
48 | /* Private functions ---------------------------------------------------------*/
49 |
50 | /**
51 | * @brief Gets Disk Status
52 | * @param pdrv: Physical drive number (0..)
53 | * @retval DSTATUS: Operation status
54 | */
55 | DSTATUS disk_status (
56 | BYTE pdrv /* Physical drive nmuber to identify the drive */
57 | )
58 | {
59 | DSTATUS stat;
60 |
61 | stat = disk.drv[pdrv]->disk_status(disk.lun[pdrv]);
62 | return stat;
63 | }
64 |
65 | /**
66 | * @brief Initializes a Drive
67 | * @param pdrv: Physical drive number (0..)
68 | * @retval DSTATUS: Operation status
69 | */
70 | DSTATUS disk_initialize (
71 | BYTE pdrv /* Physical drive nmuber to identify the drive */
72 | )
73 | {
74 | DSTATUS stat = RES_OK;
75 |
76 | if(disk.is_initialized[pdrv] == 0)
77 | {
78 | disk.is_initialized[pdrv] = 1;
79 | stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]);
80 | }
81 | return stat;
82 | }
83 |
84 | /**
85 | * @brief Reads Sector(s)
86 | * @param pdrv: Physical drive number (0..)
87 | * @param *buff: Data buffer to store read data
88 | * @param sector: Sector address (LBA)
89 | * @param count: Number of sectors to read (1..128)
90 | * @retval DRESULT: Operation result
91 | */
92 | DRESULT disk_read (
93 | BYTE pdrv, /* Physical drive nmuber to identify the drive */
94 | BYTE *buff, /* Data buffer to store read data */
95 | DWORD sector, /* Sector address in LBA */
96 | UINT count /* Number of sectors to read */
97 | )
98 | {
99 | DRESULT res;
100 |
101 | res = disk.drv[pdrv]->disk_read(disk.lun[pdrv], buff, sector, count);
102 | return res;
103 | }
104 |
105 | /**
106 | * @brief Writes Sector(s)
107 | * @param pdrv: Physical drive number (0..)
108 | * @param *buff: Data to be written
109 | * @param sector: Sector address (LBA)
110 | * @param count: Number of sectors to write (1..128)
111 | * @retval DRESULT: Operation result
112 | */
113 | #if _USE_WRITE == 1
114 | DRESULT disk_write (
115 | BYTE pdrv, /* Physical drive nmuber to identify the drive */
116 | const BYTE *buff, /* Data to be written */
117 | DWORD sector, /* Sector address in LBA */
118 | UINT count /* Number of sectors to write */
119 | )
120 | {
121 | DRESULT res;
122 |
123 | res = disk.drv[pdrv]->disk_write(disk.lun[pdrv], buff, sector, count);
124 | return res;
125 | }
126 | #endif /* _USE_WRITE == 1 */
127 |
128 | /**
129 | * @brief I/O control operation
130 | * @param pdrv: Physical drive number (0..)
131 | * @param cmd: Control code
132 | * @param *buff: Buffer to send/receive control data
133 | * @retval DRESULT: Operation result
134 | */
135 | #if _USE_IOCTL == 1
136 | DRESULT disk_ioctl (
137 | BYTE pdrv, /* Physical drive nmuber (0..) */
138 | BYTE cmd, /* Control code */
139 | void *buff /* Buffer to send/receive control data */
140 | )
141 | {
142 | DRESULT res;
143 |
144 | res = disk.drv[pdrv]->disk_ioctl(disk.lun[pdrv], cmd, buff);
145 | return res;
146 | }
147 | #endif /* _USE_IOCTL == 1 */
148 |
149 | /**
150 | * @brief Gets Time from RTC
151 | * @param None
152 | * @retval Time in DWORD
153 | */
154 | __weak DWORD get_fattime (void)
155 | {
156 | return 0;
157 | }
158 |
159 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
160 |
161 |
--------------------------------------------------------------------------------
/EEVBlog/Middlewares/Third_Party/FatFs/src/diskio.h:
--------------------------------------------------------------------------------
1 | /*-----------------------------------------------------------------------/
2 | / Low level disk interface modlue include file (C)ChaN, 2014 /
3 | /-----------------------------------------------------------------------*/
4 |
5 | #ifndef _DISKIO_DEFINED
6 | #define _DISKIO_DEFINED
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | #define _USE_WRITE 1 /* 1: Enable disk_write function */
13 | #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
14 |
15 | #include "integer.h"
16 |
17 |
18 | /* Status of Disk Functions */
19 | typedef BYTE DSTATUS;
20 |
21 | /* Results of Disk Functions */
22 | typedef enum {
23 | RES_OK = 0, /* 0: Successful */
24 | RES_ERROR, /* 1: R/W Error */
25 | RES_WRPRT, /* 2: Write Protected */
26 | RES_NOTRDY, /* 3: Not Ready */
27 | RES_PARERR /* 4: Invalid Parameter */
28 | } DRESULT;
29 |
30 |
31 | /*---------------------------------------*/
32 | /* Prototypes for disk control functions */
33 |
34 |
35 | DSTATUS disk_initialize (BYTE pdrv);
36 | DSTATUS disk_status (BYTE pdrv);
37 | DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
38 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
39 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
40 | DWORD get_fattime (void);
41 |
42 | /* Disk Status Bits (DSTATUS) */
43 |
44 | #define STA_NOINIT 0x01 /* Drive not initialized */
45 | #define STA_NODISK 0x02 /* No medium in the drive */
46 | #define STA_PROTECT 0x04 /* Write protected */
47 |
48 |
49 | /* Command code for disk_ioctrl fucntion */
50 |
51 | /* Generic command (Used by FatFs) */
52 | #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
53 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
54 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
55 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
56 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
57 |
58 | /* Generic command (Not used by FatFs) */
59 | #define CTRL_POWER 5 /* Get/Set power status */
60 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */
61 | #define CTRL_EJECT 7 /* Eject media */
62 | #define CTRL_FORMAT 8 /* Create physical format on the media */
63 |
64 | /* MMC/SDC specific ioctl command */
65 | #define MMC_GET_TYPE 10 /* Get card type */
66 | #define MMC_GET_CSD 11 /* Get CSD */
67 | #define MMC_GET_CID 12 /* Get CID */
68 | #define MMC_GET_OCR 13 /* Get OCR */
69 | #define MMC_GET_SDSTAT 14 /* Get SD status */
70 |
71 | /* ATA/CF specific ioctl command */
72 | #define ATA_GET_REV 20 /* Get F/W revision */
73 | #define ATA_GET_MODEL 21 /* Get model name */
74 | #define ATA_GET_SN 22 /* Get serial number */
75 |
76 | #ifdef __cplusplus
77 | }
78 | #endif
79 |
80 | #endif
81 |
--------------------------------------------------------------------------------
/EEVBlog/Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file sd_diskio.c
4 | * @author MCD Application Team
5 | * @version V1.3.0
6 | * @date 08-May-2015
7 | * @brief SD Disk I/O driver
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2015 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include
30 | #include "ff_gen_drv.h"
31 |
32 | /* Private typedef -----------------------------------------------------------*/
33 | /* Private define ------------------------------------------------------------*/
34 | /* Block Size in Bytes */
35 | #define BLOCK_SIZE 512
36 |
37 | /* Private variables ---------------------------------------------------------*/
38 | /* Disk status */
39 | static volatile DSTATUS Stat = STA_NOINIT;
40 |
41 | /* Private function prototypes -----------------------------------------------*/
42 | DSTATUS SD_initialize (BYTE);
43 | DSTATUS SD_status (BYTE);
44 | DRESULT SD_read (BYTE, BYTE*, DWORD, UINT);
45 | #if _USE_WRITE == 1
46 | DRESULT SD_write (BYTE, const BYTE*, DWORD, UINT);
47 | #endif /* _USE_WRITE == 1 */
48 | #if _USE_IOCTL == 1
49 | DRESULT SD_ioctl (BYTE, BYTE, void*);
50 | #endif /* _USE_IOCTL == 1 */
51 |
52 | const Diskio_drvTypeDef SD_Driver =
53 | {
54 | SD_initialize,
55 | SD_status,
56 | SD_read,
57 | #if _USE_WRITE == 1
58 | SD_write,
59 | #endif /* _USE_WRITE == 1 */
60 |
61 | #if _USE_IOCTL == 1
62 | SD_ioctl,
63 | #endif /* _USE_IOCTL == 1 */
64 | };
65 |
66 | /* Private functions ---------------------------------------------------------*/
67 |
68 | /**
69 | * @brief Initializes a Drive
70 | * @param lun : not used
71 | * @retval DSTATUS: Operation status
72 | */
73 | DSTATUS SD_initialize(BYTE lun)
74 | {
75 | Stat = STA_NOINIT;
76 |
77 | /* Configure the uSD device */
78 | if(BSP_SD_Init() == MSD_OK)
79 | {
80 | Stat &= ~STA_NOINIT;
81 | }
82 |
83 | return Stat;
84 | }
85 |
86 | /**
87 | * @brief Gets Disk Status
88 | * @param lun : not used
89 | * @retval DSTATUS: Operation status
90 | */
91 | DSTATUS SD_status(BYTE lun)
92 | {
93 | Stat = STA_NOINIT;
94 |
95 | if(BSP_SD_GetStatus() == MSD_OK)
96 | {
97 | Stat &= ~STA_NOINIT;
98 | }
99 |
100 | return Stat;
101 | }
102 |
103 | /**
104 | * @brief Reads Sector(s)
105 | * @param lun : not used
106 | * @param *buff: Data buffer to store read data
107 | * @param sector: Sector address (LBA)
108 | * @param count: Number of sectors to read (1..128)
109 | * @retval DRESULT: Operation result
110 | */
111 | DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
112 | {
113 | DRESULT res = RES_OK;
114 |
115 | if(BSP_SD_ReadBlocks((uint32_t*)buff,
116 | (uint64_t) (sector * BLOCK_SIZE),
117 | BLOCK_SIZE,
118 | count) != MSD_OK)
119 | {
120 | res = RES_ERROR;
121 | }
122 |
123 | return res;
124 | }
125 |
126 | /**
127 | * @brief Writes Sector(s)
128 | * @param lun : not used
129 | * @param *buff: Data to be written
130 | * @param sector: Sector address (LBA)
131 | * @param count: Number of sectors to write (1..128)
132 | * @retval DRESULT: Operation result
133 | */
134 | #if _USE_WRITE == 1
135 | DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
136 | {
137 | DRESULT res = RES_OK;
138 |
139 | if(BSP_SD_WriteBlocks((uint32_t*)buff,
140 | (uint64_t)(sector * BLOCK_SIZE),
141 | BLOCK_SIZE, count) != MSD_OK)
142 | {
143 | res = RES_ERROR;
144 | }
145 |
146 | return res;
147 | }
148 | #endif /* _USE_WRITE == 1 */
149 |
150 | /**
151 | * @brief I/O control operation
152 | * @param lun : not used
153 | * @param cmd: Control code
154 | * @param *buff: Buffer to send/receive control data
155 | * @retval DRESULT: Operation result
156 | */
157 | #if _USE_IOCTL == 1
158 | DRESULT SD_ioctl(BYTE lun, BYTE cmd, void *buff)
159 | {
160 | DRESULT res = RES_ERROR;
161 | SD_CardInfo CardInfo;
162 |
163 | if (Stat & STA_NOINIT) return RES_NOTRDY;
164 |
165 | switch (cmd)
166 | {
167 | /* Make sure that no pending write process */
168 | case CTRL_SYNC :
169 | res = RES_OK;
170 | break;
171 |
172 | /* Get number of sectors on the disk (DWORD) */
173 | case GET_SECTOR_COUNT :
174 | BSP_SD_GetCardInfo(&CardInfo);
175 | *(DWORD*)buff = CardInfo.CardCapacity / BLOCK_SIZE;
176 | res = RES_OK;
177 | break;
178 |
179 | /* Get R/W sector size (WORD) */
180 | case GET_SECTOR_SIZE :
181 | *(WORD*)buff = BLOCK_SIZE;
182 | res = RES_OK;
183 | break;
184 |
185 | /* Get erase block size in unit of sector (DWORD) */
186 | case GET_BLOCK_SIZE :
187 | *(DWORD*)buff = BLOCK_SIZE;
188 | break;
189 |
190 | default:
191 | res = RES_PARERR;
192 | }
193 |
194 | return res;
195 | }
196 | #endif /* _USE_IOCTL == 1 */
197 |
198 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
199 |
200 |
--------------------------------------------------------------------------------
/EEVBlog/Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file sd_diskio.h
4 | * @author MCD Application Team
5 | * @version V1.3.0
6 | * @date 08-May-2015
7 | * @brief Header for sd_diskio.c module
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2015 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __SD_DISKIO_H
30 | #define __SD_DISKIO_H
31 |
32 | /* Includes ------------------------------------------------------------------*/
33 | /* Exported types ------------------------------------------------------------*/
34 | /* Exported constants --------------------------------------------------------*/
35 | /* Exported functions ------------------------------------------------------- */
36 | extern Diskio_drvTypeDef SD_Driver;
37 |
38 | #endif /* __SD_DISKIO_H */
39 |
40 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
41 |
42 |
--------------------------------------------------------------------------------
/EEVBlog/Middlewares/Third_Party/FatFs/src/ff_gen_drv.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file ff_gen_drv.c
4 | * @author MCD Application Team
5 | * @version V1.3.0
6 | * @date 08-May-2015
7 | * @brief FatFs generic low level driver.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2015 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "ff_gen_drv.h"
30 |
31 | /* Private typedef -----------------------------------------------------------*/
32 | /* Private define ------------------------------------------------------------*/
33 | /* Private variables ---------------------------------------------------------*/
34 | Disk_drvTypeDef disk = {{0},{0},{0},0};
35 |
36 | /* Private function prototypes -----------------------------------------------*/
37 | /* Private functions ---------------------------------------------------------*/
38 |
39 | /**
40 | * @brief Links a compatible diskio driver/lun id and increments the number of active
41 | * linked drivers.
42 | * @note The number of linked drivers (volumes) is up to 10 due to FatFs limits.
43 | * @param drv: pointer to the disk IO Driver structure
44 | * @param path: pointer to the logical drive path
45 | * @param lun : only used for USB Key Disk to add multi-lun management
46 | else the paramter must be equal to 0
47 | * @retval Returns 0 in case of success, otherwise 1.
48 | */
49 | uint8_t FATFS_LinkDriverEx(Diskio_drvTypeDef *drv, char *path, uint8_t lun)
50 | {
51 | uint8_t ret = 1;
52 | uint8_t DiskNum = 0;
53 |
54 | if(disk.nbr <= _VOLUMES)
55 | {
56 | disk.is_initialized[disk.nbr] = 0;
57 | disk.drv[disk.nbr] = drv;
58 | disk.lun[disk.nbr] = lun;
59 | DiskNum = disk.nbr++;
60 | path[0] = DiskNum + '0';
61 | path[1] = ':';
62 | path[2] = '/';
63 | path[3] = 0;
64 | ret = 0;
65 | }
66 |
67 | return ret;
68 | }
69 |
70 | /**
71 | * @brief Links a compatible diskio driver and increments the number of active
72 | * linked drivers.
73 | * @note The number of linked drivers (volumes) is up to 10 due to FatFs limits
74 | * @param drv: pointer to the disk IO Driver structure
75 | * @param path: pointer to the logical drive path
76 | * @retval Returns 0 in case of success, otherwise 1.
77 | */
78 | uint8_t FATFS_LinkDriver(Diskio_drvTypeDef *drv, char *path)
79 | {
80 | return FATFS_LinkDriverEx(drv, path, 0);
81 | }
82 |
83 | /**
84 | * @brief Unlinks a diskio driver and decrements the number of active linked
85 | * drivers.
86 | * @param path: pointer to the logical drive path
87 | * @param lun : not used
88 | * @retval Returns 0 in case of success, otherwise 1.
89 | */
90 | uint8_t FATFS_UnLinkDriverEx(char *path, uint8_t lun)
91 | {
92 | uint8_t DiskNum = 0;
93 | uint8_t ret = 1;
94 |
95 | if(disk.nbr >= 1)
96 | {
97 | DiskNum = path[0] - '0';
98 | if(disk.drv[DiskNum] != 0)
99 | {
100 | disk.drv[DiskNum] = 0;
101 | disk.lun[DiskNum] = 0;
102 | disk.nbr--;
103 | ret = 0;
104 | }
105 | }
106 |
107 | return ret;
108 | }
109 |
110 | /**
111 | * @brief Unlinks a diskio driver and decrements the number of active linked
112 | * drivers.
113 | * @param path: pointer to the logical drive path
114 | * @retval Returns 0 in case of success, otherwise 1.
115 | */
116 | uint8_t FATFS_UnLinkDriver(char *path)
117 | {
118 | return FATFS_UnLinkDriverEx(path, 0);
119 | }
120 |
121 | /**
122 | * @brief Gets number of linked drivers to the FatFs module.
123 | * @param None
124 | * @retval Number of attached drivers.
125 | */
126 | uint8_t FATFS_GetAttachedDriversNbr(void)
127 | {
128 | return disk.nbr;
129 | }
130 |
131 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
132 |
133 |
--------------------------------------------------------------------------------
/EEVBlog/Middlewares/Third_Party/FatFs/src/ff_gen_drv.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file ff_gen_drv.h
4 | * @author MCD Application Team
5 | * @version V1.3.0
6 | * @date 08-May-2015
7 | * @brief Header for ff_gen_drv.c module.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2015 STMicroelectronics
12 | *
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14 | * You may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at:
16 | *
17 | * http://www.st.com/software_license_agreement_liberty_v2
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | *
25 | ******************************************************************************
26 | */
27 |
28 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __FF_GEN_DRV_H
30 | #define __FF_GEN_DRV_H
31 |
32 | #ifdef __cplusplus
33 | extern "C" {
34 | #endif
35 |
36 | /* Includes ------------------------------------------------------------------*/
37 | #include "diskio.h"
38 | #include "ff.h"
39 |
40 | /* Exported types ------------------------------------------------------------*/
41 |
42 | /**
43 | * @brief Disk IO Driver structure definition
44 | */
45 | typedef struct
46 | {
47 | DSTATUS (*disk_initialize) (BYTE); /*!< Initialize Disk Drive */
48 | DSTATUS (*disk_status) (BYTE); /*!< Get Disk Status */
49 | DRESULT (*disk_read) (BYTE, BYTE*, DWORD, UINT); /*!< Read Sector(s) */
50 | #if _USE_WRITE == 1
51 | DRESULT (*disk_write) (BYTE, const BYTE*, DWORD, UINT); /*!< Write Sector(s) when _USE_WRITE = 0 */
52 | #endif /* _USE_WRITE == 1 */
53 | #if _USE_IOCTL == 1
54 | DRESULT (*disk_ioctl) (BYTE, BYTE, void*); /*!< I/O control operation when _USE_IOCTL = 1 */
55 | #endif /* _USE_IOCTL == 1 */
56 |
57 | }Diskio_drvTypeDef;
58 |
59 | /**
60 | * @brief Global Disk IO Drivers structure definition
61 | */
62 | typedef struct
63 | {
64 | uint8_t is_initialized[_VOLUMES];
65 | Diskio_drvTypeDef *drv[_VOLUMES];
66 | uint8_t lun[_VOLUMES];
67 | __IO uint8_t nbr;
68 |
69 | }Disk_drvTypeDef;
70 |
71 | /* Exported constants --------------------------------------------------------*/
72 | /* Exported macro ------------------------------------------------------------*/
73 | /* Exported functions ------------------------------------------------------- */
74 | uint8_t FATFS_LinkDriverEx(Diskio_drvTypeDef *drv, char *path, uint8_t lun);
75 | uint8_t FATFS_LinkDriver(Diskio_drvTypeDef *drv, char *path);
76 | uint8_t FATFS_UnLinkDriver(char *path);
77 | uint8_t FATFS_LinkDriverEx(Diskio_drvTypeDef *drv, char *path, BYTE lun);
78 | uint8_t FATFS_UnLinkDriverEx(char *path, BYTE lun);
79 | uint8_t FATFS_GetAttachedDriversNbr(void);
80 |
81 | #ifdef __cplusplus
82 | }
83 | #endif
84 |
85 | #endif /* __FF_GEN_DRV_H */
86 |
87 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
88 |
89 |
--------------------------------------------------------------------------------
/EEVBlog/Middlewares/Third_Party/FatFs/src/integer.h:
--------------------------------------------------------------------------------
1 | /*-------------------------------------------*/
2 | /* Integer type definitions for FatFs module */
3 | /*-------------------------------------------*/
4 |
5 | #ifndef _FF_INTEGER
6 | #define _FF_INTEGER
7 |
8 | #ifdef _WIN32 /* FatFs development platform */
9 |
10 | #include
11 | #include
12 |
13 | #else /* Embedded platform */
14 |
15 | /* This type MUST be 8 bit */
16 | typedef unsigned char BYTE;
17 |
18 | /* These types MUST be 16 bit */
19 | typedef short SHORT;
20 | typedef unsigned short WORD;
21 | typedef unsigned short WCHAR;
22 |
23 | /* These types MUST be 16 bit or 32 bit */
24 | typedef int INT;
25 | typedef unsigned int UINT;
26 |
27 | /* These types MUST be 32 bit */
28 | typedef long LONG;
29 | typedef unsigned long DWORD;
30 |
31 | #endif
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/EEVBlog/Middlewares/Third_Party/FatFs/src/option/syscall.c:
--------------------------------------------------------------------------------
1 | /*------------------------------------------------------------------------*/
2 | /* Sample code of OS dependent controls for FatFs */
3 | /* (C)ChaN, 2014 */
4 | /*------------------------------------------------------------------------*/
5 |
6 | #include /* ANSI memory controls */
7 | #include "../ff.h"
8 |
9 | #if _FS_REENTRANT
10 | /*-----------------------------------------------------------------------
11 | Create a Synchronization Object
12 | ------------------------------------------------------------------------
13 | This function is called in f_mount function to create a new
14 | synchronization object, such as semaphore and mutex. When a zero is
15 | returned, the f_mount function fails with FR_INT_ERR.
16 | */
17 |
18 | int ff_cre_syncobj ( /* TRUE:Function succeeded, FALSE:Could not create due to any error */
19 | BYTE vol, /* Corresponding logical drive being processed */
20 | _SYNC_t *sobj /* Pointer to return the created sync object */
21 | )
22 | {
23 | int ret;
24 |
25 | osSemaphoreDef(SEM);
26 | *sobj = osSemaphoreCreate(osSemaphore(SEM), 1);
27 | ret = (*sobj != NULL);
28 |
29 | return ret;
30 | }
31 |
32 |
33 |
34 | /*------------------------------------------------------------------------*/
35 | /* Delete a Synchronization Object */
36 | /*------------------------------------------------------------------------*/
37 | /* This function is called in f_mount function to delete a synchronization
38 | / object that created with ff_cre_syncobj function. When a zero is
39 | / returned, the f_mount function fails with FR_INT_ERR.
40 | */
41 |
42 | int ff_del_syncobj ( /* TRUE:Function succeeded, FALSE:Could not delete due to any error */
43 | _SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
44 | )
45 | {
46 | osSemaphoreDelete (sobj);
47 | return 1;
48 | }
49 |
50 |
51 |
52 | /*------------------------------------------------------------------------*/
53 | /* Request Grant to Access the Volume */
54 | /*------------------------------------------------------------------------*/
55 | /* This function is called on entering file functions to lock the volume.
56 | / When a zero is returned, the file function fails with FR_TIMEOUT.
57 | */
58 |
59 | int ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
60 | _SYNC_t sobj /* Sync object to wait */
61 | )
62 | {
63 | int ret = 0;
64 |
65 | if(osSemaphoreWait(sobj, _FS_TIMEOUT) == osOK)
66 | {
67 | ret = 1;
68 | }
69 |
70 | return ret;
71 | }
72 |
73 |
74 |
75 | /*------------------------------------------------------------------------*/
76 | /* Release Grant to Access the Volume */
77 | /*------------------------------------------------------------------------*/
78 | /* This function is called on leaving file functions to unlock the volume.
79 | */
80 |
81 | void ff_rel_grant (
82 | _SYNC_t sobj /* Sync object to be signaled */
83 | )
84 | {
85 | osSemaphoreRelease(sobj);
86 | }
87 |
88 | #endif
89 |
90 |
91 |
92 |
93 | #if _USE_LFN == 3 /* LFN with a working buffer on the heap */
94 | /*------------------------------------------------------------------------*/
95 | /* Allocate a memory block */
96 | /*------------------------------------------------------------------------*/
97 | /* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE.
98 | */
99 |
100 | void* ff_memalloc ( /* Returns pointer to the allocated memory block */
101 | UINT msize /* Number of bytes to allocate */
102 | )
103 | {
104 | return malloc(msize); /* Allocate a new memory block with POSIX API */
105 | }
106 |
107 |
108 | /*------------------------------------------------------------------------*/
109 | /* Free a memory block */
110 | /*------------------------------------------------------------------------*/
111 |
112 | void ff_memfree (
113 | void* mblock /* Pointer to the memory block to free */
114 | )
115 | {
116 | free(mblock); /* Discard the memory block with POSIX API */
117 | }
118 |
119 | #endif
120 |
--------------------------------------------------------------------------------
/EEVBlog/STM32L152ZDTx_FLASH.ld:
--------------------------------------------------------------------------------
1 | /*
2 | *****************************************************************************
3 | **
4 |
5 | ** File : LinkerScript.ld
6 | **
7 | ** Abstract : Linker script for STM32L152ZDTx Device with
8 | ** 384KByte FLASH, 48KByte RAM
9 | **
10 | ** Set heap size, stack size and stack location according
11 | ** to application requirements.
12 | **
13 | ** Set memory bank area and size if external memory is used.
14 | **
15 | ** Target : STMicroelectronics STM32
16 | **
17 | **
18 | ** Distribution: The file is distributed as is, without any warranty
19 | ** of any kind.
20 | **
21 | ** (c)Copyright Ac6.
22 | ** You may use this file as-is or modify it according to the needs of your
23 | ** project. Distribution of this file (unmodified or modified) is not
24 | ** permitted. Ac6 permit registered System Workbench for MCU users the
25 | ** rights to distribute the assembled, compiled & linked contents of this
26 | ** file as part of an application binary file, provided that it is built
27 | ** using the System Workbench for MCU toolchain.
28 | **
29 | *****************************************************************************
30 | */
31 |
32 | /* Entry Point */
33 | ENTRY(Reset_Handler)
34 |
35 | /* Highest address of the user mode stack */
36 | _estack = 0x2000C000; /* end of RAM */
37 | /* Generate a link error if heap and stack don't fit into RAM */
38 | _Min_Heap_Size = 0x200; /* required amount of heap */
39 | _Min_Stack_Size = 0x400; /* required amount of stack */
40 |
41 | /* Specify the memory areas */
42 | MEMORY
43 | {
44 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K
45 | FLASH (rx) : ORIGIN = 0x8006000, LENGTH = 360K
46 | }
47 |
48 | /* Define output sections */
49 | SECTIONS
50 | {
51 | /* The startup code goes first into FLASH */
52 | .isr_vector :
53 | {
54 | . = ALIGN(4);
55 | KEEP(*(.isr_vector)) /* Startup code */
56 | . = ALIGN(4);
57 | } >FLASH
58 |
59 | /* The program code and other data goes into FLASH */
60 | .text :
61 | {
62 | . = ALIGN(4);
63 | *(.text) /* .text sections (code) */
64 | *(.text*) /* .text* sections (code) */
65 | *(.glue_7) /* glue arm to thumb code */
66 | *(.glue_7t) /* glue thumb to arm code */
67 | *(.eh_frame)
68 |
69 | KEEP (*(.init))
70 | KEEP (*(.fini))
71 |
72 | . = ALIGN(4);
73 | _etext = .; /* define a global symbols at end of code */
74 | } >FLASH
75 |
76 | /* Constant data goes into FLASH */
77 | .rodata :
78 | {
79 | . = ALIGN(4);
80 | *(.rodata) /* .rodata sections (constants, strings, etc.) */
81 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
82 | . = ALIGN(4);
83 | } >FLASH
84 |
85 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
86 | .ARM : {
87 | __exidx_start = .;
88 | *(.ARM.exidx*)
89 | __exidx_end = .;
90 | } >FLASH
91 |
92 | .preinit_array :
93 | {
94 | PROVIDE_HIDDEN (__preinit_array_start = .);
95 | KEEP (*(.preinit_array*))
96 | PROVIDE_HIDDEN (__preinit_array_end = .);
97 | } >FLASH
98 | .init_array :
99 | {
100 | PROVIDE_HIDDEN (__init_array_start = .);
101 | KEEP (*(SORT(.init_array.*)))
102 | KEEP (*(.init_array*))
103 | PROVIDE_HIDDEN (__init_array_end = .);
104 | } >FLASH
105 | .fini_array :
106 | {
107 | PROVIDE_HIDDEN (__fini_array_start = .);
108 | KEEP (*(SORT(.fini_array.*)))
109 | KEEP (*(.fini_array*))
110 | PROVIDE_HIDDEN (__fini_array_end = .);
111 | } >FLASH
112 |
113 | /* used by the startup to initialize data */
114 | _sidata = LOADADDR(.data);
115 |
116 | /* Initialized data sections goes into RAM, load LMA copy after code */
117 | .data :
118 | {
119 | . = ALIGN(4);
120 | _sdata = .; /* create a global symbol at data start */
121 | *(.data) /* .data sections */
122 | *(.data*) /* .data* sections */
123 |
124 | . = ALIGN(4);
125 | _edata = .; /* define a global symbol at data end */
126 | } >RAM AT> FLASH
127 |
128 |
129 | /* Uninitialized data section */
130 | . = ALIGN(4);
131 | .bss :
132 | {
133 | /* This is used by the startup in order to initialize the .bss secion */
134 | _sbss = .; /* define a global symbol at bss start */
135 | __bss_start__ = _sbss;
136 | *(.bss)
137 | *(.bss*)
138 | *(COMMON)
139 |
140 | . = ALIGN(4);
141 | _ebss = .; /* define a global symbol at bss end */
142 | __bss_end__ = _ebss;
143 | } >RAM
144 |
145 | /* User_heap_stack section, used to check that there is enough RAM left */
146 | ._user_heap_stack :
147 | {
148 | . = ALIGN(8);
149 | PROVIDE ( end = . );
150 | PROVIDE ( _end = . );
151 | . = . + _Min_Heap_Size;
152 | . = . + _Min_Stack_Size;
153 | . = ALIGN(8);
154 | } >RAM
155 |
156 |
157 |
158 | /* Remove information from the standard libraries */
159 | /DISCARD/ :
160 | {
161 | libc.a ( * )
162 | libm.a ( * )
163 | libgcc.a ( * )
164 | }
165 |
166 | .ARM.attributes 0 : { *(.ARM.attributes) }
167 | }
168 |
169 |
170 |
--------------------------------------------------------------------------------
/EEVBlog/Src/fatfs.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file fatfs.c
4 | * @brief Code for fatfs applications
5 | ******************************************************************************
6 | * This notice applies to any and all portions of this file
7 | * that are not between comment pairs USER CODE BEGIN and
8 | * USER CODE END. Other portions of this file, whether
9 | * inserted by the user or by software development tools
10 | * are owned by their respective copyright owners.
11 | *
12 | * Copyright (c) 2018 STMicroelectronics International N.V.
13 | * All rights reserved.
14 | *
15 | * Redistribution and use in source and binary forms, with or without
16 | * modification, are permitted, provided that the following conditions are met:
17 | *
18 | * 1. Redistribution of source code must retain the above copyright notice,
19 | * this list of conditions and the following disclaimer.
20 | * 2. Redistributions in binary form must reproduce the above copyright notice,
21 | * this list of conditions and the following disclaimer in the documentation
22 | * and/or other materials provided with the distribution.
23 | * 3. Neither the name of STMicroelectronics nor the names of other
24 | * contributors to this software may be used to endorse or promote products
25 | * derived from this software without specific written permission.
26 | * 4. This software, including modifications and/or derivative works of this
27 | * software, must execute solely and exclusively on microcontroller or
28 | * microprocessor devices manufactured by or for STMicroelectronics.
29 | * 5. Redistribution and use of this software other than as permitted under
30 | * this license is void and will automatically terminate your rights under
31 | * this license.
32 | *
33 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
34 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
35 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
36 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
37 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
38 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
39 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
41 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
42 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
43 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
44 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 | *
46 | ******************************************************************************
47 | */
48 |
49 | #include "fatfs.h"
50 |
51 | uint8_t retSD; /* Return value for SD */
52 | char SDPath[4]; /* SD logical drive path */
53 | FATFS SDFatFS; /* File system object for SD logical drive */
54 | FIL SDFile; /* File object for SD */
55 |
56 | /* USER CODE BEGIN Variables */
57 |
58 | /* USER CODE END Variables */
59 |
60 | void MX_FATFS_Init(void)
61 | {
62 | /*## FatFS: Link the SD driver ###########################*/
63 | retSD = FATFS_LinkDriver(&SD_Driver, SDPath);
64 |
65 | /* USER CODE BEGIN Init */
66 | /* additional user code for init */
67 | /* USER CODE END Init */
68 | }
69 |
70 | /**
71 | * @brief Gets Time from RTC
72 | * @param None
73 | * @retval Time in DWORD
74 | */
75 | DWORD get_fattime(void)
76 | {
77 | /* USER CODE BEGIN get_fattime */
78 | return 0;
79 | /* USER CODE END get_fattime */
80 | }
81 |
82 | /* USER CODE BEGIN Application */
83 |
84 | /* USER CODE END Application */
85 |
86 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
87 |
--------------------------------------------------------------------------------
/EEVBlog/Src/stm32l1xx_it.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32l1xx_it.c
4 | * @brief Interrupt Service Routines.
5 | ******************************************************************************
6 | *
7 | * COPYRIGHT(c) 2018 STMicroelectronics
8 | *
9 | * Redistribution and use in source and binary forms, with or without modification,
10 | * are permitted provided that the following conditions are met:
11 | * 1. Redistributions of source code must retain the above copyright notice,
12 | * this list of conditions and the following disclaimer.
13 | * 2. Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
17 | * may be used to endorse or promote products derived from this software
18 | * without specific prior written permission.
19 | *
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *
31 | ******************************************************************************
32 | */
33 | /* Includes ------------------------------------------------------------------*/
34 | #include "stm32l1xx_hal.h"
35 | #include "stm32l1xx.h"
36 | #include "stm32l1xx_it.h"
37 |
38 | /* USER CODE BEGIN 0 */
39 |
40 | /* USER CODE END 0 */
41 |
42 | /* External variables --------------------------------------------------------*/
43 | extern DMA_HandleTypeDef hdma_sd_mmc;
44 |
45 | /******************************************************************************/
46 | /* Cortex-M3 Processor Interruption and Exception Handlers */
47 | /******************************************************************************/
48 |
49 | /**
50 | * @brief This function handles Non maskable interrupt.
51 | */
52 | void NMI_Handler(void)
53 | {
54 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
55 |
56 | /* USER CODE END NonMaskableInt_IRQn 0 */
57 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
58 |
59 | /* USER CODE END NonMaskableInt_IRQn 1 */
60 | }
61 |
62 | /**
63 | * @brief This function handles Hard fault interrupt.
64 | */
65 | void HardFault_Handler(void)
66 | {
67 | /* USER CODE BEGIN HardFault_IRQn 0 */
68 |
69 | /* USER CODE END HardFault_IRQn 0 */
70 | while (1)
71 | {
72 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */
73 | /* USER CODE END W1_HardFault_IRQn 0 */
74 | }
75 | /* USER CODE BEGIN HardFault_IRQn 1 */
76 |
77 | /* USER CODE END HardFault_IRQn 1 */
78 | }
79 |
80 | /**
81 | * @brief This function handles Memory management fault.
82 | */
83 | void MemManage_Handler(void)
84 | {
85 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */
86 |
87 | /* USER CODE END MemoryManagement_IRQn 0 */
88 | while (1)
89 | {
90 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
91 | /* USER CODE END W1_MemoryManagement_IRQn 0 */
92 | }
93 | /* USER CODE BEGIN MemoryManagement_IRQn 1 */
94 |
95 | /* USER CODE END MemoryManagement_IRQn 1 */
96 | }
97 |
98 | /**
99 | * @brief This function handles Pre-fetch fault, memory access fault.
100 | */
101 | void BusFault_Handler(void)
102 | {
103 | /* USER CODE BEGIN BusFault_IRQn 0 */
104 |
105 | /* USER CODE END BusFault_IRQn 0 */
106 | while (1)
107 | {
108 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */
109 | /* USER CODE END W1_BusFault_IRQn 0 */
110 | }
111 | /* USER CODE BEGIN BusFault_IRQn 1 */
112 |
113 | /* USER CODE END BusFault_IRQn 1 */
114 | }
115 |
116 | /**
117 | * @brief This function handles Undefined instruction or illegal state.
118 | */
119 | void UsageFault_Handler(void)
120 | {
121 | /* USER CODE BEGIN UsageFault_IRQn 0 */
122 |
123 | /* USER CODE END UsageFault_IRQn 0 */
124 | while (1)
125 | {
126 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
127 | /* USER CODE END W1_UsageFault_IRQn 0 */
128 | }
129 | /* USER CODE BEGIN UsageFault_IRQn 1 */
130 |
131 | /* USER CODE END UsageFault_IRQn 1 */
132 | }
133 |
134 | /**
135 | * @brief This function handles System service call via SWI instruction.
136 | */
137 | void SVC_Handler(void)
138 | {
139 | /* USER CODE BEGIN SVC_IRQn 0 */
140 |
141 | /* USER CODE END SVC_IRQn 0 */
142 | /* USER CODE BEGIN SVC_IRQn 1 */
143 |
144 | /* USER CODE END SVC_IRQn 1 */
145 | }
146 |
147 | /**
148 | * @brief This function handles Debug monitor.
149 | */
150 | void DebugMon_Handler(void)
151 | {
152 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */
153 |
154 | /* USER CODE END DebugMonitor_IRQn 0 */
155 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */
156 |
157 | /* USER CODE END DebugMonitor_IRQn 1 */
158 | }
159 |
160 | /**
161 | * @brief This function handles Pendable request for system service.
162 | */
163 | void PendSV_Handler(void)
164 | {
165 | /* USER CODE BEGIN PendSV_IRQn 0 */
166 |
167 | /* USER CODE END PendSV_IRQn 0 */
168 | /* USER CODE BEGIN PendSV_IRQn 1 */
169 |
170 | /* USER CODE END PendSV_IRQn 1 */
171 | }
172 |
173 | /**
174 | * @brief This function handles System tick timer.
175 | */
176 | void SysTick_Handler(void)
177 | {
178 | /* USER CODE BEGIN SysTick_IRQn 0 */
179 |
180 | /* USER CODE END SysTick_IRQn 0 */
181 | HAL_IncTick();
182 | HAL_SYSTICK_IRQHandler();
183 | /* USER CODE BEGIN SysTick_IRQn 1 */
184 |
185 | /* USER CODE END SysTick_IRQn 1 */
186 | }
187 |
188 | /******************************************************************************/
189 | /* STM32L1xx Peripheral Interrupt Handlers */
190 | /* Add here the Interrupt Handlers for the used peripherals. */
191 | /* For the available peripheral interrupt handler names, */
192 | /* please refer to the startup file (startup_stm32l1xx.s). */
193 | /******************************************************************************/
194 |
195 | /**
196 | * @brief This function handles DMA2 channel4 global interrupt.
197 | */
198 | void DMA2_Channel4_IRQHandler(void)
199 | {
200 | /* USER CODE BEGIN DMA2_Channel4_IRQn 0 */
201 |
202 | /* USER CODE END DMA2_Channel4_IRQn 0 */
203 | HAL_DMA_IRQHandler(&hdma_sd_mmc);
204 | /* USER CODE BEGIN DMA2_Channel4_IRQn 1 */
205 |
206 | /* USER CODE END DMA2_Channel4_IRQn 1 */
207 | }
208 |
209 | /* USER CODE BEGIN 1 */
210 |
211 | /* USER CODE END 1 */
212 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
213 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | 88mph
2 | Copyright 2018 Thomas Watson
3 |
4 | This product includes software that is a part of
5 | 88mph (https://github.com/tpwrules/121gw-88mph/).
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Introduction
2 | Welcome to 88mph, the unofficial firmware for the [EEVBlog 121GW](https://www.eevblog.com/product/121gw/) multimeter. This project aims to make available the full functionality of the meter, while prioritizing understandability, usability, and hackability.
3 |
4 | *"If my programming is correct, when this meter reaches 88mph, you're going to measure some serious s#!t!"*
5 | ~ Doc Brown (paraphrased)
6 |
7 | **DISCLAIMER:** If you intend to use this firmware in situations where an incorrect or misleading reading could put you or others at risk of injury or financial loss, then this is not the firmware for you. Please use the official firmware, or another meter entirely.
8 |
9 | ## Installation and Usage
10 |
11 | Unfortunately, 88mph is not yet functional or stable enough for a binary release. Please check back later!
12 |
13 | ## Contributing
14 |
15 | Unfortunately, 88mph is not yet functional or stable enough to be worthy of contributions. I need to do more work and establish the conventions I want others to follow. Please check back later!
16 |
17 | ## Project Goals
18 |
19 | I think these goals can help guide the project to something useful for everyone. I'm not saying that help will be rejected which does not meet every letter of every goal, but I intend for myself and others to refer to them when making choices. Specific ideas I have in mind to accomplish these goals are also written below.
20 |
21 | 1. Transparency: The meter's behavior should be easy to understand and explain, and well documented.
22 | * Consolidate and generalize behavior. The antithesis of the official firmware.
23 | * Keep code modular, and carefully document interactions between modules.
24 | * Inform the user of illegal operations and invalid states. Document why these might happen and how to resolve them.
25 | 2. Testability: The meter's behavior should be backed up by scientific proofs and experiments that anyone can verify (with appropriate equipment). Choices in measurement algorithms and settings should be made with scientifically sound and testable reasoning.
26 | * Documented procedures to perform specific tests. Work with forum members to develop effective tests.
27 | * Research why the existing firmware works the way it does, and how it can be improved.
28 | 3. Usability: The meter itself should remain easy to pick up and use. Sensible defaults should be in place, and advanced customization can be left to SD card configuration files or a BLE app.
29 | * Better use of buttons and setup menu
30 | * Use the factory calibration data as much as possible, but offer a way to improve it
31 | * Way to access official firmware from 88mph. Will talk with Dave about this.
32 | 4. Hackability: The firmware should be designed with modification in mind. The steps required to change or add behavior should be clear. Additionally, infrastructure must be in place to support the testing and experimentation required for the other goals.
33 | * Modularity will help here. Allow additions to tables and such so that behavior can be extended.
34 | * Create Bluetooth console to change every setting and detail so that specific experiments can be set up and documented and don't require reprogramming to fiddle.
35 |
36 | The project also has anti-goals, which are goals that the project will specifically avoid.
37 | 1. Absolute performance: Prefer an understandable but less accurate solution over an unexplainable but more accurate one. Similarly, prefer a simple and modular but slower solution to one that is faster but total spaghetti code.
38 | * It is my belief that any solution can be retooled to honor the above goals. This rule is to prevent lazy hacks that will complicate the future.
39 | 2. Identical behavior: The behavior documented in the official manual will be used as a guide, but will not necessarily be adhered to. Doing so would limit the freedom to fix usability niggles. The exception is that the buttons and switches must continue to work as documented on the meter body itself.
40 | * Regarding the exception, let's think about the HOLD button. In 88mph, pressing the HOLD button will still activate the HOLD function. However, the operation of the function may be different, and of course documented. Perhaps the sensitivity will change, or the type of hold selected when the button is pressed will change.
41 | * Specifically I don't like the setup menu and the subscreen choice menu. I will be implementing my own ideas for those.
42 | * Several features and buttons have quirks that will be addressed and behavior that must be documented. For example, the auto-hold feature waits for a "stable" reading, and will re-hold once the measurement changes "significantly". In 88mph, definitions will be established according to the Goals, and the feature will be implemented accordingly, without regard to their definition in the official firmware.
43 | 3. Compatible data protocols: The logging format and Bluetooth protocol will be written from scratch, as they are dependent on the internal structure of the official firmware and have several deficiencies.
44 | * CSV is CSV; as far as I know there are no tools which rely on the exact official format so there is no need to preserve it. The new one will be similar.
45 | * Bluetooth measurement is tricker. The official format has no opening for improvements or changes. I intend to write PC-compatible scripts to implement the new Bluetooth behavior (such as the Bluetooth console), but I'm not writing more phone apps. Since the Bluetooth apps are entirely Dave's property, maybe I can reach an agreement with him to implement relevant parts of the unofficial protocol in his apps, or to change the official protocol to have room for expansion.
46 |
47 | ## License
48 | Except where otherwise specified, 88mph is licensed under the Apache 2.0 license according to the notice below.
49 |
50 | Copyright 2018 Thomas Watson
51 |
52 | This file is a part of 88mph: https://github.com/tpwrules/121gw-88mph/
53 |
54 | Licensed under the Apache License, Version 2.0 (the "License");
55 | you may not use this file except in compliance with the License.
56 | You may obtain a copy of the License at
57 |
58 | http://www.apache.org/licenses/LICENSE-2.0
59 |
60 | Unless required by applicable law or agreed to in writing, software
61 | distributed under the License is distributed on an "AS IS" BASIS,
62 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
63 | See the License for the specific language governing permissions and
64 | limitations under the License.
65 |
66 | STMicroelectronics and ARM hardware libraries are excluded from this license.
--------------------------------------------------------------------------------