Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7799cdc871 | |||
| 53c2820cc4 | |||
| bf83a6c0eb | |||
| d192bac6c9 | |||
| 8cd4d9b60e | |||
| 4f8fe7ba39 | |||
| d145aa3661 |
@@ -24,7 +24,7 @@
|
|||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.755606893" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.755606893" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1771260818" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1771260818" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1811760675" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F407VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F407xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F407VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1811760675" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F407VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F407xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F407VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.2006503660" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="16" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.2006503660" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="32" valueType="string"/>
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.188797436" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.188797436" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||||
<builder buildPath="${workspace_loc:/test1}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.901063855" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
<builder buildPath="${workspace_loc:/test1}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.901063855" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1851291017" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1851291017" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.1646548773" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.1646548773" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1901965124" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1901965124" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.859080388" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F407VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F407xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F407VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.859080388" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F407VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F407xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F407VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1202403298" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="16" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1202403298" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="32" valueType="string"/>
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.584865598" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.584865598" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||||
<builder buildPath="${workspace_loc:/test1}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1873374287" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
<builder buildPath="${workspace_loc:/test1}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1873374287" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1806292512" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1806292512" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef __DHT11
|
||||||
|
#define __DHT11
|
||||||
|
|
||||||
|
#define SKIP_LOW while (!(GPIOD->IDR & 0x0800)) {}
|
||||||
|
#define SKIP_HIGH while (GPIOD->IDR & 0x0800) {}
|
||||||
|
|
||||||
|
__attribute__((packed))
|
||||||
|
struct DHT11_Data {
|
||||||
|
uint8_t humid_integral;
|
||||||
|
uint8_t humid_decimal;
|
||||||
|
uint8_t temp_integral;
|
||||||
|
uint8_t temp_decimal;
|
||||||
|
uint8_t crc;
|
||||||
|
};
|
||||||
|
|
||||||
|
int DHT11_run_test(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -13,9 +13,9 @@ int EEPROM_24AA02E48_run_test(void)
|
|||||||
size_t err_count = 0;
|
size_t err_count = 0;
|
||||||
|
|
||||||
// write the Address Pointer register
|
// write the Address Pointer register
|
||||||
uint8_t data_buffer[13];
|
uint8_t data_buffer[9];
|
||||||
data_buffer[12] = '\0';
|
data_buffer[8] = '\0';
|
||||||
data_buffer[0] = 0xF4;
|
data_buffer[0] = 0xF8;
|
||||||
|
|
||||||
for (size_t t = 0; t < 5; t++) {
|
for (size_t t = 0; t < 5; t++) {
|
||||||
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xA0, data_buffer, 1, 2000);
|
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xA0, data_buffer, 1, 2000);
|
||||||
@@ -26,7 +26,7 @@ int EEPROM_24AA02E48_run_test(void)
|
|||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("24AA02E48 EEPROM");
|
display_write_data_seq("24AA02E48 EEPROM");
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("W ");
|
display_write_data_seq("W ");
|
||||||
display_write_data_byte('1' + t);
|
display_write_data_byte('1' + t);
|
||||||
display_write_data_seq("/5 ");
|
display_write_data_seq("/5 ");
|
||||||
@@ -52,7 +52,7 @@ int EEPROM_24AA02E48_run_test(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (size_t t = 0; t < 5; t++) {
|
for (size_t t = 0; t < 5; t++) {
|
||||||
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xA1, data_buffer, 12, 2000);
|
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xA1, data_buffer, 8, 2000);
|
||||||
|
|
||||||
if (op_result) {
|
if (op_result) {
|
||||||
err_count++;
|
err_count++;
|
||||||
@@ -60,7 +60,7 @@ int EEPROM_24AA02E48_run_test(void)
|
|||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("24AA02E48 EEPROM");
|
display_write_data_seq("24AA02E48 EEPROM");
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("R ");
|
display_write_data_seq("R ");
|
||||||
display_write_data_byte('1' + t);
|
display_write_data_byte('1' + t);
|
||||||
display_write_data_seq("/5 ");
|
display_write_data_seq("/5 ");
|
||||||
@@ -89,15 +89,15 @@ int EEPROM_24AA02E48_run_test(void)
|
|||||||
display_write_data_seq("24AA02E48 EEPROM");
|
display_write_data_seq("24AA02E48 EEPROM");
|
||||||
|
|
||||||
if (err_count) {
|
if (err_count) {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('0' + err_count / 10 % 10);
|
display_write_data_byte('0' + (err_count / 10) % 10);
|
||||||
display_write_data_byte('0' + err_count % 10);
|
display_write_data_byte('0' + err_count % 10);
|
||||||
display_write_data_seq("E ");
|
display_write_data_seq("E ");
|
||||||
display_write_data_seq((char *) data_buffer);
|
display_write_data_seq((char *) data_buffer);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("OK ");
|
display_write_data_seq("OK ");
|
||||||
display_write_data_seq((char *) data_buffer);
|
display_write_data_seq((char *) data_buffer);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -54,13 +54,13 @@ int CS43L22_run_test(void)
|
|||||||
display_write_data_seq("CS43L22 Audio");
|
display_write_data_seq("CS43L22 Audio");
|
||||||
|
|
||||||
if (err_count) {
|
if (err_count) {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('0' + err_count % 10);
|
display_write_data_byte('0' + err_count % 10);
|
||||||
display_write_data_seq(" Errors");
|
display_write_data_seq(" Errors");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "generic_macros.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "DHT11.h"
|
||||||
|
|
||||||
|
extern TIM_HandleTypeDef htim2;
|
||||||
|
|
||||||
|
static inline void wait(uint32_t wait_us)
|
||||||
|
{
|
||||||
|
uint32_t target_time = TIM2->CNT;
|
||||||
|
target_time += wait_us << 4;
|
||||||
|
|
||||||
|
while (TIM2->CNT < target_time) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline size_t dht11_measure_high_duration(void)
|
||||||
|
{
|
||||||
|
SKIP_LOW;
|
||||||
|
uint32_t start_time = TIM2->CNT;
|
||||||
|
SKIP_HIGH;
|
||||||
|
uint32_t end_time = TIM2->CNT;
|
||||||
|
|
||||||
|
// elapsed_time > 49us ? 1 : 0
|
||||||
|
return (end_time - start_time) > (49 << 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t dht11_read_value(struct DHT11_Data *data)
|
||||||
|
{
|
||||||
|
// treat data as a normal array to simplify read loop
|
||||||
|
uint8_t *buffer = (uint8_t *) data;
|
||||||
|
|
||||||
|
register uint32_t read_register = 0;
|
||||||
|
|
||||||
|
TIM2->CNT = 0;
|
||||||
|
HAL_TIM_Base_Start(&htim2);
|
||||||
|
|
||||||
|
GPIOD->MODER |= 0x00400000; // enable output mode on GPIOD 11
|
||||||
|
|
||||||
|
GPIOD->BSRR = GPIO_PIN_11; // enable DHT11
|
||||||
|
wait(50000); // hold HIGH for 50 ms
|
||||||
|
GPIOD->BSRR = GPIO_PIN_11 << 16; // start signal
|
||||||
|
wait(30000); // hold it for 30 ms
|
||||||
|
GPIOD->BSRR = GPIO_PIN_11; // pull up, DHT will now take control over the connection
|
||||||
|
|
||||||
|
wait(100);
|
||||||
|
GPIOD->MODER &= 0xFF3FFFFF; // switch GPIOD 11 to input mode
|
||||||
|
|
||||||
|
// reading pull down from DHT11
|
||||||
|
SKIP_LOW;
|
||||||
|
|
||||||
|
// waiting for 500ms max
|
||||||
|
for (size_t i = TIM2->CNT + (500000 << 4); TIM2->CNT <= i; )
|
||||||
|
if (!(GPIOD->IDR & 0x0800))
|
||||||
|
goto reading_data;
|
||||||
|
|
||||||
|
// if didn't exit through goto, then DHT11 awaiting has timed out
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
reading_data:
|
||||||
|
// read 5 bytes of data
|
||||||
|
for (size_t i = 0; i < 5; i++) {
|
||||||
|
for (register size_t j = 0; j < 8; j++) {
|
||||||
|
read_register <<= 1;
|
||||||
|
read_register |= dht11_measure_high_duration();
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[i] = (uint8_t) read_register;
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_TIM_Base_Stop(&htim2);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DHT11_run_test(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("DHT11 Temp+Humid");
|
||||||
|
|
||||||
|
struct DHT11_Data data;
|
||||||
|
size_t result = dht11_read_value(&data);
|
||||||
|
|
||||||
|
size_t checksum_mismatch = ((
|
||||||
|
data.humid_decimal
|
||||||
|
+ data.humid_integral
|
||||||
|
+ data.temp_decimal
|
||||||
|
+ data.temp_integral
|
||||||
|
) & 0xFF) != data.crc;
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
|
display_write_data_seq("StartTimeout");
|
||||||
|
} else if (checksum_mismatch) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
|
display_write_data_seq("CRC Fault");
|
||||||
|
} else {
|
||||||
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 7);
|
||||||
|
display_write_data_byte('0' + (data.humid_integral/10)%10);
|
||||||
|
display_write_data_byte('0' + (data.humid_integral)%10);
|
||||||
|
display_write_data_seq("% ");
|
||||||
|
|
||||||
|
display_write_data_byte('0' + (data.temp_integral/10)%10);
|
||||||
|
display_write_data_byte('0' + (data.temp_integral)%10);
|
||||||
|
display_write_data_byte('.');
|
||||||
|
display_write_data_byte('0' + data.temp_decimal);
|
||||||
|
display_write_data_seq("C");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (result || checksum_mismatch);
|
||||||
|
}
|
||||||
+43
-30
@@ -3,25 +3,23 @@
|
|||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "DNI.h"
|
#include "DNI.h"
|
||||||
|
|
||||||
static uint32_t DNI_read(void)
|
static int DNI_read(void)
|
||||||
{
|
{
|
||||||
HAL_ADC_Start(&hadc1);
|
HAL_ADC_Start(&hadc1);
|
||||||
if (HAL_ADC_PollForConversion(&hadc1, 100) != HAL_OK)
|
|
||||||
PANIC(0x4000);
|
|
||||||
|
|
||||||
|
HAL_StatusTypeDef s = HAL_ADC_PollForConversion(&hadc1, 100);
|
||||||
|
|
||||||
|
if (HAL_OK != s)
|
||||||
|
return -s;
|
||||||
|
else
|
||||||
return HAL_ADC_GetValue(&hadc1);
|
return HAL_ADC_GetValue(&hadc1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DNI_convert_to_celsius(uint32_t value)
|
static int DNI_convert_to_celsius(int value)
|
||||||
{
|
{
|
||||||
return (2512 - value) << 2;
|
return (2512 - value) << 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DNI_convert_to_fahrenheit(uint32_t value)
|
|
||||||
{
|
|
||||||
return (2953 - value) * 50 / 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DNI_print(int temperature)
|
static void DNI_print(int temperature)
|
||||||
{
|
{
|
||||||
int add_sign = temperature < 0;
|
int add_sign = temperature < 0;
|
||||||
@@ -50,27 +48,48 @@ static void DNI_print(int temperature)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (add_sign) {
|
if (add_sign) {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 9);
|
||||||
display_write_data_byte('-');
|
display_write_data_byte('-');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DNI_print_celsius(int temperature)
|
static void DNI_print_celsius(int temperature)
|
||||||
{
|
{
|
||||||
DISPLAY_SET_CURSOR(1, 7);
|
DISPLAY_SET_CURSOR(1, 15);
|
||||||
DISPLAY_SET_DECREMENT;
|
DISPLAY_SET_DECREMENT;
|
||||||
display_write_data_seq("C ");
|
display_write_data_seq("C ");
|
||||||
|
|
||||||
DNI_print(temperature);
|
DNI_print(temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DNI_print_fahrenheit(int temperature)
|
static void print_ok(void)
|
||||||
{
|
{
|
||||||
DISPLAY_SET_CURSOR(1, 7);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
DISPLAY_SET_DECREMENT;
|
DISPLAY_SET_INCREMENT;
|
||||||
display_write_data_seq("F ");
|
display_write_data_seq("OK");
|
||||||
|
}
|
||||||
|
|
||||||
DNI_print(temperature);
|
static void print_error(int err_code)
|
||||||
|
{
|
||||||
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
|
DISPLAY_SET_INCREMENT;
|
||||||
|
|
||||||
|
switch (err_code) {
|
||||||
|
case HAL_OK:
|
||||||
|
break;
|
||||||
|
case HAL_ERROR:
|
||||||
|
display_write_data_seq("HAL_ERROR");
|
||||||
|
break;
|
||||||
|
case HAL_BUSY:
|
||||||
|
display_write_data_seq("HAL_BUSY");
|
||||||
|
break;
|
||||||
|
case HAL_TIMEOUT:
|
||||||
|
display_write_data_seq("HAL_TIMEOUT");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
display_write_data_seq("WRONG ERROR");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DNI_show_celsius(void)
|
int DNI_show_celsius(void)
|
||||||
@@ -80,23 +99,17 @@ int DNI_show_celsius(void)
|
|||||||
|
|
||||||
display_write_data_seq("DNI Temperature");
|
display_write_data_seq("DNI Temperature");
|
||||||
|
|
||||||
uint32_t value = DNI_read();
|
int value = DNI_read();
|
||||||
|
|
||||||
|
if (value < 0) {
|
||||||
|
print_error(-value);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
int temp = DNI_convert_to_celsius(value);
|
int temp = DNI_convert_to_celsius(value);
|
||||||
DNI_print_celsius(temp);
|
DNI_print_celsius(temp);
|
||||||
|
|
||||||
return 0;
|
print_ok();
|
||||||
}
|
|
||||||
|
|
||||||
int DNI_show_fahrenheit(void)
|
|
||||||
{
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
DISPLAY_SET_INCREMENT;
|
|
||||||
|
|
||||||
display_write_data_seq("DNI Temperature");
|
|
||||||
|
|
||||||
uint32_t value = DNI_read();
|
|
||||||
int temp = DNI_convert_to_fahrenheit(value);
|
|
||||||
DNI_print_fahrenheit(temp);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
+11
-11
@@ -33,7 +33,7 @@ static void print_error_message(HAL_StatusTypeDef result, size_t *err_count, siz
|
|||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("LIS302DL Accel ");
|
display_write_data_seq("LIS302DL Accel ");
|
||||||
display_write_data_seq(postfix);
|
display_write_data_seq(postfix);
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq(prefix);
|
display_write_data_seq(prefix);
|
||||||
display_write_data_byte(' ');
|
display_write_data_byte(' ');
|
||||||
|
|
||||||
@@ -125,14 +125,14 @@ int LIS302DL_run_test(void)
|
|||||||
|
|
||||||
// print the execution stats
|
// print the execution stats
|
||||||
if (err_count) {
|
if (err_count) {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('0' + err_count / 10 % 10);
|
display_write_data_byte('0' + (err_count / 10) % 10);
|
||||||
display_write_data_byte('0' + err_count % 10);
|
display_write_data_byte('0' + err_count % 10);
|
||||||
display_write_data_seq(" errs");
|
display_write_data_seq(" errs");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -152,23 +152,23 @@ int LIS302DL_run_test_dynamic(void)
|
|||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("LIS302DL Accel D");
|
display_write_data_seq("LIS302DL Accel D");
|
||||||
|
|
||||||
// output retrieved values
|
|
||||||
print_at(data_xyz[2], 14);
|
|
||||||
print_at(data_xyz[1], 11);
|
|
||||||
print_at(data_xyz[0], 8);
|
|
||||||
|
|
||||||
// print the execution stats
|
// print the execution stats
|
||||||
if (err_count) {
|
if (err_count) {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('0' + err_count / 10 % 10);
|
display_write_data_byte('0' + err_count / 10 % 10);
|
||||||
display_write_data_byte('0' + err_count % 10);
|
display_write_data_byte('0' + err_count % 10);
|
||||||
display_write_data_seq(" errs");
|
display_write_data_seq(" errs");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
// output retrieved values
|
||||||
|
print_at(data_xyz[2], 14);
|
||||||
|
print_at(data_xyz[1], 11);
|
||||||
|
print_at(data_xyz[0], 8);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -10,7 +10,7 @@ extern I2C_HandleTypeDef hi2c1;
|
|||||||
|
|
||||||
static void print_error_message(HAL_StatusTypeDef result, size_t *err_count, size_t t, char *prefix)
|
static void print_error_message(HAL_StatusTypeDef result, size_t *err_count, size_t t, char *prefix)
|
||||||
{
|
{
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq(prefix);
|
display_write_data_seq(prefix);
|
||||||
display_write_data_byte(' ');
|
display_write_data_byte(' ');
|
||||||
|
|
||||||
@@ -82,12 +82,12 @@ int LSM9DS1_test_accel(void)
|
|||||||
FAILSAFE_POST_OP_ACCEL("R");
|
FAILSAFE_POST_OP_ACCEL("R");
|
||||||
|
|
||||||
if (!err_count) {
|
if (!err_count) {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('0' + ((err_count / 10) % 10));
|
display_write_data_byte('0' + ((err_count / 10) % 10));
|
||||||
display_write_data_byte('0' + (err_count % 10));
|
display_write_data_byte('0' + (err_count % 10));
|
||||||
display_write_data_seq(" errors");
|
display_write_data_seq(" errors");
|
||||||
@@ -124,12 +124,12 @@ int LSM9DS1_test_magnet(void)
|
|||||||
FAILSAFE_POST_OP_MAGNET("R");
|
FAILSAFE_POST_OP_MAGNET("R");
|
||||||
|
|
||||||
if (!err_count) {
|
if (!err_count) {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('0' + ((err_count / 10) % 10));
|
display_write_data_byte('0' + ((err_count / 10) % 10));
|
||||||
display_write_data_byte('0' + (err_count % 10));
|
display_write_data_byte('0' + (err_count % 10));
|
||||||
display_write_data_seq(" errors");
|
display_write_data_seq(" errors");
|
||||||
|
|||||||
+7
-7
@@ -22,12 +22,12 @@ int MP45DT02_run_test(void)
|
|||||||
display_write_data_seq("MP45DT02 Mic");
|
display_write_data_seq("MP45DT02 Mic");
|
||||||
|
|
||||||
if (!t) {
|
if (!t) {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('0' + t);
|
display_write_data_byte('0' + t);
|
||||||
display_write_data_seq(" full 0 samples");
|
display_write_data_seq(" 0 samples");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -37,9 +37,9 @@ int MP45DT02_run_test(void)
|
|||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("MP45DT02 Mic");
|
display_write_data_seq("MP45DT02 Mic");
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('1' + t);
|
display_write_data_byte('1' + t);
|
||||||
display_write_data_seq("/5: no 1 sampled");
|
display_write_data_seq("/5: all zeros");
|
||||||
|
|
||||||
HAL_Delay(1000);
|
HAL_Delay(1000);
|
||||||
}
|
}
|
||||||
@@ -48,8 +48,8 @@ int MP45DT02_run_test(void)
|
|||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("MP45DT02 Mic");
|
display_write_data_seq("MP45DT02 Mic");
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("No good samples!");
|
display_write_data_seq("NO ONES");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -30,7 +30,7 @@ int PCA9685_run_test(void)
|
|||||||
|
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("PCA9685 PWM");
|
display_write_data_seq("PCA9685 PWM");
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
|
|
||||||
display_write_data_seq("B");
|
display_write_data_seq("B");
|
||||||
display_write_data_byte('0' + i);
|
display_write_data_byte('0' + i);
|
||||||
@@ -64,14 +64,14 @@ int PCA9685_run_test(void)
|
|||||||
display_write_data_seq("PCA9685 PWM");
|
display_write_data_seq("PCA9685 PWM");
|
||||||
|
|
||||||
if (err_count) {
|
if (err_count) {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('0' + err_count / 10 % 10);
|
display_write_data_byte('0' + err_count / 10 % 10);
|
||||||
display_write_data_byte('0' + err_count % 10);
|
display_write_data_byte('0' + err_count % 10);
|
||||||
display_write_data_seq(" errors");
|
display_write_data_seq(" errors");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ int SST25VF016B_run_test(void)
|
|||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("SST25VF016B Flas");
|
display_write_data_seq("SST25VF016B Flas");
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('1' + t);
|
display_write_data_byte('1' + t);
|
||||||
display_write_data_seq("/5 ");
|
display_write_data_seq("/5 ");
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ int SST25VF016B_run_test(void)
|
|||||||
display_write_data_seq("SST25VF016B Flas");
|
display_write_data_seq("SST25VF016B Flas");
|
||||||
|
|
||||||
if (err_count) {
|
if (err_count) {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('0' + err_count % 10);
|
display_write_data_byte('0' + err_count % 10);
|
||||||
display_write_data_seq(" Errors");
|
display_write_data_seq(" Errors");
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ int SST25VF016B_run_test(void)
|
|||||||
for (size_t i = 0; i < 4; i += 2) {
|
for (size_t i = 0; i < 4; i += 2) {
|
||||||
// odd reads MUST result in 0xBF
|
// odd reads MUST result in 0xBF
|
||||||
if (rx_buffer[4+i] != 0xBF) {
|
if (rx_buffer[4+i] != 0xBF) {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('B');
|
display_write_data_byte('B');
|
||||||
display_write_data_byte('1'+i);
|
display_write_data_byte('1'+i);
|
||||||
display_write_data_seq(" WRONG");
|
display_write_data_seq(" WRONG");
|
||||||
@@ -81,7 +81,7 @@ int SST25VF016B_run_test(void)
|
|||||||
for (size_t i = 1; i < 4; i += 2) {
|
for (size_t i = 1; i < 4; i += 2) {
|
||||||
// even reads MUST result in 0x41
|
// even reads MUST result in 0x41
|
||||||
if (rx_buffer[4+i] != 0x41) {
|
if (rx_buffer[4+i] != 0x41) {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('B');
|
display_write_data_byte('B');
|
||||||
display_write_data_byte('1'+i);
|
display_write_data_byte('1'+i);
|
||||||
display_write_data_seq(" WRONG");
|
display_write_data_seq(" WRONG");
|
||||||
@@ -92,7 +92,7 @@ int SST25VF016B_run_test(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+50
-100
@@ -32,6 +32,7 @@
|
|||||||
#include "LIS302DL.h"
|
#include "LIS302DL.h"
|
||||||
#include "MP45DT02.h"
|
#include "MP45DT02.h"
|
||||||
#include "LSM9DS1.h"
|
#include "LSM9DS1.h"
|
||||||
|
#include "DHT11.h"
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
@@ -75,10 +76,10 @@ SPI_HandleTypeDef hspi1;
|
|||||||
|
|
||||||
TIM_HandleTypeDef htim2;
|
TIM_HandleTypeDef htim2;
|
||||||
|
|
||||||
extern size_t display_current_frame;
|
|
||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
|
extern size_t display_current_frame;
|
||||||
|
|
||||||
static const int ((*executors[])(void)) = {
|
static const int ((*executors[])(void)) = {
|
||||||
DNI_show_celsius,
|
DNI_show_celsius,
|
||||||
PCA9685_run_test,
|
PCA9685_run_test,
|
||||||
@@ -88,7 +89,8 @@ static const int ((*executors[])(void)) = {
|
|||||||
LIS302DL_run_test,
|
LIS302DL_run_test,
|
||||||
MP45DT02_run_test,
|
MP45DT02_run_test,
|
||||||
LSM9DS1_test_accel,
|
LSM9DS1_test_accel,
|
||||||
LSM9DS1_test_magnet
|
LSM9DS1_test_magnet,
|
||||||
|
DHT11_run_test
|
||||||
};
|
};
|
||||||
|
|
||||||
static const void ((*cleanup_functions[])(void)) = {
|
static const void ((*cleanup_functions[])(void)) = {
|
||||||
@@ -100,6 +102,7 @@ static const void ((*cleanup_functions[])(void)) = {
|
|||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
LSM9DS1_cleanup_accel,
|
LSM9DS1_cleanup_accel,
|
||||||
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,72 +123,6 @@ static void MX_I2S2_Init(void);
|
|||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
static void button_init_and_test(void)
|
|
||||||
{
|
|
||||||
// letting the buttons be tested
|
|
||||||
display_write_data_seq("Fill any bar:");
|
|
||||||
DISPLAY_SET_CURSOR(1, 5);
|
|
||||||
display_write_data_seq("[-] [-----]");
|
|
||||||
|
|
||||||
size_t pressed_elements;
|
|
||||||
|
|
||||||
uint32_t sw_button_locations[5][2] = {
|
|
||||||
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_11},
|
|
||||||
{(uint32_t) GPIOA, (uint32_t) GPIO_PIN_15},
|
|
||||||
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_9},
|
|
||||||
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_6},
|
|
||||||
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_8}
|
|
||||||
};
|
|
||||||
|
|
||||||
do {
|
|
||||||
HAL_Delay(100);
|
|
||||||
pressed_elements = 0;
|
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 6);
|
|
||||||
|
|
||||||
if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0)) {
|
|
||||||
pressed_elements |= 0x20;
|
|
||||||
display_write_data_byte('*');
|
|
||||||
} else {
|
|
||||||
display_write_data_byte('-');
|
|
||||||
}
|
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 10);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < 5; i++) {
|
|
||||||
pressed_elements >>= 1;
|
|
||||||
|
|
||||||
size_t input = !HAL_GPIO_ReadPin((GPIO_TypeDef *) sw_button_locations[i][0], sw_button_locations[i][1]);
|
|
||||||
|
|
||||||
if (input) {
|
|
||||||
pressed_elements |= 0x20;
|
|
||||||
display_write_data_byte('*');
|
|
||||||
} else {
|
|
||||||
display_write_data_byte('-');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (!(((pressed_elements & 0x1) == 0x1) || ((pressed_elements & 0x3E) == 0x3E)));
|
|
||||||
|
|
||||||
|
|
||||||
// visual reaction to bar fill
|
|
||||||
DISPLAY_SET_CURSOR(0, 0);
|
|
||||||
display_write_data_seq("Release buttons");
|
|
||||||
|
|
||||||
GPIOD->ODR = 0x1000;
|
|
||||||
HAL_Delay(300);
|
|
||||||
GPIOD->ODR = 0x2000;
|
|
||||||
HAL_Delay(300);
|
|
||||||
GPIOD->ODR = 0x4000;
|
|
||||||
HAL_Delay(300);
|
|
||||||
GPIOD->ODR = 0x8000;
|
|
||||||
HAL_Delay(300);
|
|
||||||
|
|
||||||
// waiting for all buttons to be released
|
|
||||||
WAIT_UNTIL_ALL_BUTTONS_RELEASED;
|
|
||||||
GPIOD->ODR = 0x0000;
|
|
||||||
HAL_Delay(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -224,20 +161,17 @@ int main(void)
|
|||||||
MX_I2S2_Init();
|
MX_I2S2_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
HAL_TIM_Base_Start(&htim2);
|
GPIOD->BSRR = 0x1000;
|
||||||
TIM2->CNT = 0;
|
|
||||||
HAL_TIM_Base_Stop(&htim2);
|
|
||||||
|
|
||||||
GPIOD->ODR = 0x1000;
|
|
||||||
display_init();
|
display_init();
|
||||||
|
|
||||||
GPIOD->ODR = 0xF000;
|
GPIOD->BSRR = 0xF000;
|
||||||
button_init_and_test();
|
|
||||||
|
|
||||||
// perform all tests
|
// perform all tests
|
||||||
size_t successful_tests = 0;
|
size_t successful_tests = 0;
|
||||||
size_t failed_tests = 0;
|
size_t failed_tests = 0;
|
||||||
|
|
||||||
|
const int test_amount = LEN(executors);
|
||||||
|
|
||||||
for (display_current_frame = 1; display_current_frame < LEN(executors)+1; display_current_frame++)
|
for (display_current_frame = 1; display_current_frame < LEN(executors)+1; display_current_frame++)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
@@ -265,6 +199,13 @@ int main(void)
|
|||||||
if (cleanup_functions[display_current_frame-1])
|
if (cleanup_functions[display_current_frame-1])
|
||||||
cleanup_functions[display_current_frame-1]();
|
cleanup_functions[display_current_frame-1]();
|
||||||
|
|
||||||
|
// write test number tag onto this framebuffer
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
DISPLAY_SET_INCREMENT;
|
||||||
|
display_write_data_byte('T');
|
||||||
|
display_write_data_byte('0' + (display_current_frame / 10) % 10);
|
||||||
|
display_write_data_byte('0' + display_current_frame % 10);
|
||||||
|
|
||||||
display_to_direct();
|
display_to_direct();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,17 +214,21 @@ int main(void)
|
|||||||
display_current_frame = 0;
|
display_current_frame = 0;
|
||||||
|
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
|
if (successful_tests == LEN(executors))
|
||||||
display_write_data_seq("All tests done!");
|
display_write_data_seq("All tests done!");
|
||||||
|
else
|
||||||
|
display_write_data_seq("Failures found!");
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 2);
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
display_write_data_seq("P:");
|
display_write_data_seq("PASSED /");
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 8);
|
||||||
display_write_data_byte('0' + (successful_tests / 10) % 10);
|
display_write_data_byte('0' + (successful_tests / 10) % 10);
|
||||||
display_write_data_byte('0' + (successful_tests) % 10);
|
display_write_data_byte('0' + successful_tests % 10);
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 10);
|
DISPLAY_SET_CURSOR(1, 11);
|
||||||
display_write_data_seq("F:");
|
display_write_data_byte('0' + (test_amount / 10) % 10);
|
||||||
display_write_data_byte('0' + (failed_tests / 10) % 10);
|
display_write_data_byte('0' + test_amount % 10);
|
||||||
display_write_data_byte('0' + (failed_tests) % 10);
|
|
||||||
|
|
||||||
display_to_direct();
|
display_to_direct();
|
||||||
|
|
||||||
@@ -297,6 +242,8 @@ int main(void)
|
|||||||
display_load(display_current_frame);
|
display_load(display_current_frame);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
HAL_Delay(15);
|
||||||
|
|
||||||
// go to next report
|
// go to next report
|
||||||
if (UB || SWT1 || SWT5) {
|
if (UB || SWT1 || SWT5) {
|
||||||
display_current_frame += 1;
|
display_current_frame += 1;
|
||||||
@@ -336,14 +283,6 @@ void SystemClock_Config(void)
|
|||||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||||
|
|
||||||
/** Macro to configure the PLL multiplication factor
|
|
||||||
*/
|
|
||||||
__HAL_RCC_PLL_PLLM_CONFIG(16);
|
|
||||||
|
|
||||||
/** Macro to configure the PLL clock source
|
|
||||||
*/
|
|
||||||
__HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSI);
|
|
||||||
|
|
||||||
/** Configure the main internal regulator output voltage
|
/** Configure the main internal regulator output voltage
|
||||||
*/
|
*/
|
||||||
__HAL_RCC_PWR_CLK_ENABLE();
|
__HAL_RCC_PWR_CLK_ENABLE();
|
||||||
@@ -355,8 +294,12 @@ void SystemClock_Config(void)
|
|||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
|
||||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||||
|
RCC_OscInitStruct.PLL.PLLM = 16;
|
||||||
|
RCC_OscInitStruct.PLL.PLLN = 128;
|
||||||
|
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
|
||||||
|
RCC_OscInitStruct.PLL.PLLQ = 4;
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
@@ -366,12 +309,12 @@ void SystemClock_Config(void)
|
|||||||
*/
|
*/
|
||||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
||||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV4;
|
||||||
|
|
||||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
@@ -624,10 +567,17 @@ static void MX_GPIO_Init(void)
|
|||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pins : PD11 PD12 PD13 PD14
|
/*Configure GPIO pin : PD11 */
|
||||||
PD15 PD4 PD7 */
|
GPIO_InitStruct.Pin = GPIO_PIN_11;
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : PD12 PD13 PD14 PD15
|
||||||
|
PD4 PD7 */
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15
|
||||||
|
|GPIO_PIN_4|GPIO_PIN_7;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ PC8.Locked=true
|
|||||||
PC8.Signal=GPIO_Input
|
PC8.Signal=GPIO_Input
|
||||||
PC9.Locked=true
|
PC9.Locked=true
|
||||||
PC9.Signal=GPIO_Input
|
PC9.Signal=GPIO_Input
|
||||||
|
PD11.GPIOParameters=GPIO_Speed
|
||||||
|
PD11.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
|
||||||
PD11.Locked=true
|
PD11.Locked=true
|
||||||
PD11.Signal=GPIO_Output
|
PD11.Signal=GPIO_Output
|
||||||
PD12.Locked=true
|
PD12.Locked=true
|
||||||
@@ -181,36 +183,42 @@ ProjectManager.UAScriptAfterPath=
|
|||||||
ProjectManager.UAScriptBeforePath=
|
ProjectManager.UAScriptBeforePath=
|
||||||
ProjectManager.UnderRoot=true
|
ProjectManager.UnderRoot=true
|
||||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_SPI1_Init-SPI1-false-HAL-true,6-MX_TIM2_Init-TIM2-false-HAL-true,7-MX_I2S2_Init-I2S2-false-HAL-true
|
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_SPI1_Init-SPI1-false-HAL-true,6-MX_TIM2_Init-TIM2-false-HAL-true,7-MX_I2S2_Init-I2S2-false-HAL-true
|
||||||
RCC.AHBFreq_Value=16000000
|
RCC.48MHZClocksFreq_Value=32000000
|
||||||
RCC.APB1Freq_Value=16000000
|
RCC.AHBFreq_Value=32000000
|
||||||
|
RCC.APB1CLKDivider=RCC_HCLK_DIV4
|
||||||
|
RCC.APB1Freq_Value=8000000
|
||||||
RCC.APB1TimFreq_Value=16000000
|
RCC.APB1TimFreq_Value=16000000
|
||||||
RCC.APB2Freq_Value=16000000
|
RCC.APB2CLKDivider=RCC_HCLK_DIV4
|
||||||
|
RCC.APB2Freq_Value=8000000
|
||||||
RCC.APB2TimFreq_Value=16000000
|
RCC.APB2TimFreq_Value=16000000
|
||||||
RCC.CortexFreq_Value=16000000
|
RCC.CortexFreq_Value=32000000
|
||||||
RCC.EthernetFreq_Value=16000000
|
RCC.EthernetFreq_Value=32000000
|
||||||
RCC.FCLKCortexFreq_Value=16000000
|
RCC.FCLKCortexFreq_Value=32000000
|
||||||
RCC.FamilyName=M
|
RCC.FamilyName=M
|
||||||
RCC.HCLKFreq_Value=16000000
|
RCC.HCLKFreq_Value=32000000
|
||||||
RCC.HSE_VALUE=25000000
|
RCC.HSE_VALUE=25000000
|
||||||
RCC.HSI_VALUE=16000000
|
RCC.HSI_VALUE=16000000
|
||||||
RCC.I2SClocksFreq_Value=96000000
|
RCC.I2SClocksFreq_Value=96000000
|
||||||
RCC.IPParameters=AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S
|
RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLN,PLLP,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S
|
||||||
RCC.LSE_VALUE=32768
|
RCC.LSE_VALUE=32768
|
||||||
RCC.LSI_VALUE=32000
|
RCC.LSI_VALUE=32000
|
||||||
RCC.MCO2PinFreq_Value=16000000
|
RCC.MCO2PinFreq_Value=32000000
|
||||||
RCC.PLLCLKFreq_Value=96000000
|
RCC.PLLCLKFreq_Value=32000000
|
||||||
RCC.PLLQCLKFreq_Value=48000000
|
RCC.PLLN=128
|
||||||
|
RCC.PLLP=RCC_PLLP_DIV4
|
||||||
|
RCC.PLLQCLKFreq_Value=32000000
|
||||||
RCC.RTCFreq_Value=32000
|
RCC.RTCFreq_Value=32000
|
||||||
RCC.RTCHSEDivFreq_Value=12500000
|
RCC.RTCHSEDivFreq_Value=12500000
|
||||||
RCC.SYSCLKFreq_VALUE=16000000
|
RCC.SYSCLKFreq_VALUE=32000000
|
||||||
|
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
|
||||||
RCC.VCOI2SOutputFreq_Value=192000000
|
RCC.VCOI2SOutputFreq_Value=192000000
|
||||||
RCC.VCOInputFreq_Value=1000000
|
RCC.VCOInputFreq_Value=1000000
|
||||||
RCC.VCOOutputFreq_Value=192000000
|
RCC.VCOOutputFreq_Value=128000000
|
||||||
RCC.VcooutputI2S=96000000
|
RCC.VcooutputI2S=96000000
|
||||||
SH.ADCx_IN9.0=ADC1_IN9,IN9
|
SH.ADCx_IN9.0=ADC1_IN9,IN9
|
||||||
SH.ADCx_IN9.ConfNb=1
|
SH.ADCx_IN9.ConfNb=1
|
||||||
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16
|
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16
|
||||||
SPI1.CalculateBaudRate=1000.0 KBits/s
|
SPI1.CalculateBaudRate=500.0 KBits/s
|
||||||
SPI1.Direction=SPI_DIRECTION_2LINES
|
SPI1.Direction=SPI_DIRECTION_2LINES
|
||||||
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
|
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
|
||||||
SPI1.Mode=SPI_MODE_MASTER
|
SPI1.Mode=SPI_MODE_MASTER
|
||||||
|
|||||||
Reference in New Issue
Block a user