Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 368c530602 | |||
| cad8fe1186 | |||
| 3e38106f3d | |||
| 8d119b4c14 | |||
| ae050ce8c1 | |||
| 7bae3f0989 | |||
| ab263f7948 | |||
| 1ac6300e02 |
@@ -13,9 +13,9 @@ int EEPROM_24AA02E48_run_test(void)
|
||||
size_t err_count = 0;
|
||||
|
||||
// write the Address Pointer register
|
||||
uint8_t data_buffer[9];
|
||||
data_buffer[8] = '\0';
|
||||
data_buffer[0] = 0xF8;
|
||||
uint8_t data_buffer[13];
|
||||
data_buffer[12] = '\0';
|
||||
data_buffer[0] = 0xF4;
|
||||
|
||||
for (size_t t = 0; t < 5; t++) {
|
||||
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_write_data_seq("24AA02E48 EEPROM");
|
||||
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_seq("W ");
|
||||
display_write_data_byte('1' + t);
|
||||
display_write_data_seq("/5 ");
|
||||
@@ -52,7 +52,7 @@ int EEPROM_24AA02E48_run_test(void)
|
||||
}
|
||||
|
||||
for (size_t t = 0; t < 5; t++) {
|
||||
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xA1, data_buffer, 8, 2000);
|
||||
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xA1, data_buffer, 12, 2000);
|
||||
|
||||
if (op_result) {
|
||||
err_count++;
|
||||
@@ -60,7 +60,7 @@ int EEPROM_24AA02E48_run_test(void)
|
||||
DISPLAY_CLEAR;
|
||||
display_write_data_seq("24AA02E48 EEPROM");
|
||||
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_seq("R ");
|
||||
display_write_data_byte('1' + t);
|
||||
display_write_data_seq("/5 ");
|
||||
@@ -89,15 +89,15 @@ int EEPROM_24AA02E48_run_test(void)
|
||||
display_write_data_seq("24AA02E48 EEPROM");
|
||||
|
||||
if (err_count) {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
display_write_data_byte('0' + (err_count / 10) % 10);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('0' + err_count / 10 % 10);
|
||||
display_write_data_byte('0' + err_count % 10);
|
||||
display_write_data_seq("E ");
|
||||
display_write_data_seq((char *) data_buffer);
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 1);
|
||||
display_write_data_seq("OK ");
|
||||
display_write_data_seq((char *) data_buffer);
|
||||
|
||||
|
||||
+2
-2
@@ -54,13 +54,13 @@ int CS43L22_run_test(void)
|
||||
display_write_data_seq("CS43L22 Audio");
|
||||
|
||||
if (err_count) {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 1);
|
||||
display_write_data_byte('0' + err_count % 10);
|
||||
display_write_data_seq(" Errors");
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 1);
|
||||
display_write_data_seq("OK");
|
||||
|
||||
return 0;
|
||||
|
||||
+30
-43
@@ -3,23 +3,25 @@
|
||||
#include "lcd.h"
|
||||
#include "DNI.h"
|
||||
|
||||
static int DNI_read(void)
|
||||
static uint32_t DNI_read(void)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
static int DNI_convert_to_celsius(int value)
|
||||
static int DNI_convert_to_celsius(uint32_t value)
|
||||
{
|
||||
return (2512 - value) << 2;
|
||||
}
|
||||
|
||||
static int DNI_convert_to_fahrenheit(uint32_t value)
|
||||
{
|
||||
return (2953 - value) * 50 / 7;
|
||||
}
|
||||
|
||||
static void DNI_print(int temperature)
|
||||
{
|
||||
int add_sign = temperature < 0;
|
||||
@@ -48,48 +50,27 @@ static void DNI_print(int temperature)
|
||||
}
|
||||
|
||||
if (add_sign) {
|
||||
DISPLAY_SET_CURSOR(1, 9);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('-');
|
||||
}
|
||||
}
|
||||
|
||||
static void DNI_print_celsius(int temperature)
|
||||
{
|
||||
DISPLAY_SET_CURSOR(1, 15);
|
||||
DISPLAY_SET_CURSOR(1, 7);
|
||||
DISPLAY_SET_DECREMENT;
|
||||
display_write_data_seq("C ");
|
||||
|
||||
DNI_print(temperature);
|
||||
}
|
||||
|
||||
static void print_ok(void)
|
||||
static void DNI_print_fahrenheit(int temperature)
|
||||
{
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_INCREMENT;
|
||||
display_write_data_seq("OK");
|
||||
}
|
||||
DISPLAY_SET_CURSOR(1, 7);
|
||||
DISPLAY_SET_DECREMENT;
|
||||
display_write_data_seq("F ");
|
||||
|
||||
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;
|
||||
}
|
||||
DNI_print(temperature);
|
||||
}
|
||||
|
||||
int DNI_show_celsius(void)
|
||||
@@ -99,17 +80,23 @@ int DNI_show_celsius(void)
|
||||
|
||||
display_write_data_seq("DNI Temperature");
|
||||
|
||||
int value = DNI_read();
|
||||
|
||||
if (value < 0) {
|
||||
print_error(-value);
|
||||
return 1;
|
||||
} else {
|
||||
uint32_t value = DNI_read();
|
||||
int temp = DNI_convert_to_celsius(value);
|
||||
DNI_print_celsius(temp);
|
||||
|
||||
print_ok();
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -33,7 +33,7 @@ static void print_error_message(HAL_StatusTypeDef result, size_t *err_count, siz
|
||||
DISPLAY_CLEAR;
|
||||
display_write_data_seq("LIS302DL Accel ");
|
||||
display_write_data_seq(postfix);
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_seq(prefix);
|
||||
display_write_data_byte(' ');
|
||||
|
||||
@@ -125,14 +125,14 @@ int LIS302DL_run_test(void)
|
||||
|
||||
// print the execution stats
|
||||
if (err_count) {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
display_write_data_byte('0' + (err_count / 10) % 10);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('0' + err_count / 10 % 10);
|
||||
display_write_data_byte('0' + err_count % 10);
|
||||
display_write_data_seq(" errs");
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 1);
|
||||
display_write_data_seq("OK");
|
||||
|
||||
return 0;
|
||||
@@ -152,23 +152,23 @@ int LIS302DL_run_test_dynamic(void)
|
||||
DISPLAY_CLEAR;
|
||||
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
|
||||
if (err_count) {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('0' + err_count / 10 % 10);
|
||||
display_write_data_byte('0' + err_count % 10);
|
||||
display_write_data_seq(" errs");
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 1);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
+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)
|
||||
{
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_seq(prefix);
|
||||
display_write_data_byte(' ');
|
||||
|
||||
@@ -82,12 +82,12 @@ int LSM9DS1_test_accel(void)
|
||||
FAILSAFE_POST_OP_ACCEL("R");
|
||||
|
||||
if (!err_count) {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 1);
|
||||
display_write_data_seq("OK");
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('0' + ((err_count / 10) % 10));
|
||||
display_write_data_byte('0' + (err_count % 10));
|
||||
display_write_data_seq(" errors");
|
||||
@@ -124,12 +124,12 @@ int LSM9DS1_test_magnet(void)
|
||||
FAILSAFE_POST_OP_MAGNET("R");
|
||||
|
||||
if (!err_count) {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 1);
|
||||
display_write_data_seq("OK");
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('0' + ((err_count / 10) % 10));
|
||||
display_write_data_byte('0' + (err_count % 10));
|
||||
display_write_data_seq(" errors");
|
||||
|
||||
+7
-7
@@ -22,12 +22,12 @@ int MP45DT02_run_test(void)
|
||||
display_write_data_seq("MP45DT02 Mic");
|
||||
|
||||
if (!t) {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 1);
|
||||
display_write_data_seq("OK");
|
||||
} else {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('0' + t);
|
||||
display_write_data_seq(" 0 samples");
|
||||
display_write_data_seq(" full 0 samples");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -37,9 +37,9 @@ int MP45DT02_run_test(void)
|
||||
DISPLAY_CLEAR;
|
||||
display_write_data_seq("MP45DT02 Mic");
|
||||
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('1' + t);
|
||||
display_write_data_seq("/5: all zeros");
|
||||
display_write_data_seq("/5: no 1 sampled");
|
||||
|
||||
HAL_Delay(1000);
|
||||
}
|
||||
@@ -48,8 +48,8 @@ int MP45DT02_run_test(void)
|
||||
DISPLAY_CLEAR;
|
||||
display_write_data_seq("MP45DT02 Mic");
|
||||
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
display_write_data_seq("NO ONES");
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_seq("No good samples!");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
+3
-5
@@ -30,7 +30,7 @@ int PCA9685_run_test(void)
|
||||
|
||||
DISPLAY_CLEAR;
|
||||
display_write_data_seq("PCA9685 PWM");
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
|
||||
display_write_data_seq("B");
|
||||
display_write_data_byte('0' + i);
|
||||
@@ -40,8 +40,6 @@ int PCA9685_run_test(void)
|
||||
display_write_data_seq("/5 ");
|
||||
|
||||
switch (op_result) {
|
||||
case HAL_OK:
|
||||
break;
|
||||
case HAL_ERROR:
|
||||
display_write_data_seq("ERROR");
|
||||
break;
|
||||
@@ -64,14 +62,14 @@ int PCA9685_run_test(void)
|
||||
display_write_data_seq("PCA9685 PWM");
|
||||
|
||||
if (err_count) {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('0' + err_count / 10 % 10);
|
||||
display_write_data_byte('0' + err_count % 10);
|
||||
display_write_data_seq(" errors");
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 1);
|
||||
display_write_data_seq("OK");
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -30,7 +30,7 @@ int SST25VF016B_run_test(void)
|
||||
DISPLAY_CLEAR;
|
||||
display_write_data_seq("SST25VF016B Flas");
|
||||
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('1' + t);
|
||||
display_write_data_seq("/5 ");
|
||||
|
||||
@@ -58,7 +58,7 @@ int SST25VF016B_run_test(void)
|
||||
display_write_data_seq("SST25VF016B Flas");
|
||||
|
||||
if (err_count) {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 1);
|
||||
display_write_data_byte('0' + err_count % 10);
|
||||
display_write_data_seq(" Errors");
|
||||
|
||||
@@ -67,7 +67,7 @@ int SST25VF016B_run_test(void)
|
||||
for (size_t i = 0; i < 4; i += 2) {
|
||||
// odd reads MUST result in 0xBF
|
||||
if (rx_buffer[4+i] != 0xBF) {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('B');
|
||||
display_write_data_byte('1'+i);
|
||||
display_write_data_seq(" WRONG");
|
||||
@@ -81,7 +81,7 @@ int SST25VF016B_run_test(void)
|
||||
for (size_t i = 1; i < 4; i += 2) {
|
||||
// even reads MUST result in 0x41
|
||||
if (rx_buffer[4+i] != 0x41) {
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 0);
|
||||
display_write_data_byte('B');
|
||||
display_write_data_byte('1'+i);
|
||||
display_write_data_seq(" WRONG");
|
||||
@@ -92,7 +92,7 @@ int SST25VF016B_run_test(void)
|
||||
}
|
||||
}
|
||||
|
||||
DISPLAY_SET_CURSOR(1, 4);
|
||||
DISPLAY_SET_CURSOR(1, 1);
|
||||
display_write_data_seq("OK");
|
||||
}
|
||||
|
||||
|
||||
@@ -136,12 +136,6 @@ static void display_write_data_byte_direct(uint8_t code)
|
||||
|
||||
static void display_write_data_byte_framebuffer(uint8_t code)
|
||||
{
|
||||
if (display_current_frame >= DISPLAY_FRAMES_AVAILABLE)
|
||||
return;
|
||||
|
||||
if (((int) des.cursor_offset >= 32) || ((int) des.cursor_offset < 0))
|
||||
return;
|
||||
|
||||
display_framebuffer[16*2*display_current_frame + des.cursor_offset] = (char) code;
|
||||
des.cursor_offset += des.next ? -1 : 1;
|
||||
}
|
||||
|
||||
+162
-44
@@ -46,17 +46,6 @@
|
||||
#define WAIT_UNTIL_CB_PRESSED while (!HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) && HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_8))
|
||||
#define WAIT_UNTIL_CB_RELEASED while (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) || !HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_8))
|
||||
|
||||
#define UB (GPIOA->IDR & GPIO_PIN_0)
|
||||
#define SWT1 !(GPIOC->IDR & GPIO_PIN_11)
|
||||
#define SWT2 !(GPIOA->IDR & GPIO_PIN_15)
|
||||
#define SWT3 !(GPIOC->IDR & GPIO_PIN_9)
|
||||
#define SWT4 !(GPIOC->IDR & GPIO_PIN_6)
|
||||
#define SWT5 !(GPIOC->IDR & GPIO_PIN_8)
|
||||
|
||||
#define WAIT_UNTIL_ALL_BUTTONS_RELEASED do {} while ( UB || SWT1 || SWT2 || SWT3 || SWT4 || SWT5 )
|
||||
|
||||
#define LEN(x) ( sizeof(x) / sizeof((x)[0]) )
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
@@ -79,19 +68,22 @@ extern size_t display_current_frame;
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
static const int ((*executors[])(void)) = {
|
||||
int ((*executors[])(void)) = {
|
||||
DNI_show_celsius,
|
||||
DNI_show_fahrenheit,
|
||||
PCA9685_run_test,
|
||||
EEPROM_24AA02E48_run_test,
|
||||
CS43L22_run_test,
|
||||
SST25VF016B_run_test,
|
||||
LIS302DL_run_test,
|
||||
LIS302DL_run_test_dynamic,
|
||||
MP45DT02_run_test,
|
||||
LSM9DS1_test_accel,
|
||||
LSM9DS1_test_magnet
|
||||
};
|
||||
|
||||
static const void ((*cleanup_functions[])(void)) = {
|
||||
void ((*cleanup_functions[])(void)) = {
|
||||
NULL,
|
||||
NULL,
|
||||
PCA9685_cleanup,
|
||||
NULL,
|
||||
@@ -99,10 +91,29 @@ static const void ((*cleanup_functions[])(void)) = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
LSM9DS1_cleanup_accel,
|
||||
NULL
|
||||
};
|
||||
|
||||
int delay_between_runs[] = {
|
||||
250,
|
||||
250,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
200,
|
||||
-1,
|
||||
-1,
|
||||
-1
|
||||
};
|
||||
|
||||
size_t current_executor_id = 0;
|
||||
|
||||
size_t buttons_interrupt_enabled;
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
@@ -120,7 +131,67 @@ static void MX_I2S2_Init(void);
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
static void button_init_and_test(void)
|
||||
void switch_to_next_test(void)
|
||||
{
|
||||
current_executor_id += 1;
|
||||
current_executor_id %= 11;
|
||||
}
|
||||
|
||||
void buttons_switch_to_interrupt(void)
|
||||
{
|
||||
// save current executor ID
|
||||
size_t tmp = current_executor_id;
|
||||
|
||||
// configure user button
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
|
||||
|
||||
// configure SW5 (alternative advancing method)
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
|
||||
|
||||
// restore current executor ID
|
||||
current_executor_id = tmp;
|
||||
|
||||
// set interrupt mode flag
|
||||
buttons_interrupt_enabled = 1;
|
||||
}
|
||||
|
||||
void buttons_switch_to_input(void)
|
||||
{
|
||||
// configure user button
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
HAL_NVIC_DisableIRQ(EXTI0_IRQn);
|
||||
|
||||
// configure SW5 (alternative input method)
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
HAL_NVIC_DisableIRQ(EXTI9_5_IRQn);
|
||||
|
||||
// clear interrupt mode flag
|
||||
buttons_interrupt_enabled = 0;
|
||||
}
|
||||
|
||||
void button_init_and_test(void)
|
||||
{
|
||||
// letting the buttons be tested
|
||||
display_write_data_seq("Fill any bar:");
|
||||
@@ -130,11 +201,11 @@ static void button_init_and_test(void)
|
||||
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}
|
||||
{GPIOC, GPIO_PIN_11},
|
||||
{GPIOA, GPIO_PIN_15},
|
||||
{GPIOC, GPIO_PIN_9},
|
||||
{GPIOC, GPIO_PIN_6},
|
||||
{GPIOC, GPIO_PIN_8}
|
||||
};
|
||||
|
||||
do {
|
||||
@@ -172,16 +243,16 @@ static void button_init_and_test(void)
|
||||
display_write_data_seq("Release buttons");
|
||||
|
||||
GPIOD->ODR = 0x1000;
|
||||
HAL_Delay(300);
|
||||
HAL_Delay(500);
|
||||
GPIOD->ODR = 0x2000;
|
||||
HAL_Delay(300);
|
||||
HAL_Delay(500);
|
||||
GPIOD->ODR = 0x4000;
|
||||
HAL_Delay(300);
|
||||
HAL_Delay(500);
|
||||
GPIOD->ODR = 0x8000;
|
||||
HAL_Delay(300);
|
||||
HAL_Delay(500);
|
||||
|
||||
// waiting for all buttons to be released
|
||||
WAIT_UNTIL_ALL_BUTTONS_RELEASED;
|
||||
// waiting for control buttons to be released
|
||||
WAIT_UNTIL_CB_RELEASED;
|
||||
GPIOD->ODR = 0x0000;
|
||||
HAL_Delay(200);
|
||||
}
|
||||
@@ -223,6 +294,7 @@ int main(void)
|
||||
MX_TIM2_Init();
|
||||
MX_I2S2_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
buttons_interrupt_enabled = 0;
|
||||
|
||||
HAL_TIM_Base_Start(&htim2);
|
||||
TIM2->CNT = 0;
|
||||
@@ -238,7 +310,9 @@ int main(void)
|
||||
size_t successful_tests = 0;
|
||||
size_t failed_tests = 0;
|
||||
|
||||
for (display_current_frame = 1; display_current_frame < LEN(executors)+1; display_current_frame++)
|
||||
//display_to_framebuffer();
|
||||
|
||||
for (display_current_frame = 1; display_current_frame < 12; display_current_frame++)
|
||||
{
|
||||
DISPLAY_CLEAR;
|
||||
display_write_data_seq("Testing...");
|
||||
@@ -265,13 +339,6 @@ int main(void)
|
||||
if (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();
|
||||
}
|
||||
|
||||
@@ -294,43 +361,94 @@ int main(void)
|
||||
|
||||
display_to_direct();
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
if (buttons_interrupt_enabled)
|
||||
buttons_switch_to_input();
|
||||
|
||||
while (1) {
|
||||
WAIT_UNTIL_ALL_BUTTONS_RELEASED;
|
||||
// wait until all buttons are released
|
||||
while (
|
||||
(GPIOA->IDR & GPIO_PIN_0) ||
|
||||
!(GPIOC->IDR & GPIO_PIN_11) ||
|
||||
!(GPIOC->IDR & GPIO_PIN_8) ||
|
||||
!(GPIOC->IDR & GPIO_PIN_9) ||
|
||||
!(GPIOC->IDR & GPIO_PIN_6) ||
|
||||
!(GPIOA->IDR & GPIO_PIN_15)
|
||||
) { asm("nop"); }
|
||||
|
||||
display_load(display_current_frame);
|
||||
|
||||
while (1) {
|
||||
// go to next report
|
||||
if (UB || SWT1 || SWT5) {
|
||||
if (
|
||||
(GPIOA->IDR & GPIO_PIN_0) ||
|
||||
!(GPIOC->IDR & GPIO_PIN_11) ||
|
||||
!(GPIOC->IDR & GPIO_PIN_8)
|
||||
) {
|
||||
display_current_frame += 1;
|
||||
display_current_frame %= LEN(executors)+1;
|
||||
display_current_frame %= 12;
|
||||
break;
|
||||
}
|
||||
|
||||
// go to previous report
|
||||
else if (SWT3 || SWT4) {
|
||||
else if (
|
||||
!(GPIOC->IDR & GPIO_PIN_9) ||
|
||||
!(GPIOC->IDR & GPIO_PIN_6)
|
||||
) {
|
||||
display_current_frame -= 1;
|
||||
|
||||
if ((int) display_current_frame == -1)
|
||||
display_current_frame = LEN(executors);
|
||||
if (display_current_frame == 0xFFFFFFFFU)
|
||||
display_current_frame = 11;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// return to summary frame
|
||||
else if (SWT2) {
|
||||
else if (
|
||||
!(GPIOA->IDR & GPIO_PIN_15)
|
||||
) {
|
||||
display_current_frame = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
|
||||
/*
|
||||
while (1)
|
||||
{
|
||||
if (delay_between_runs[current_executor_id] == -1 && buttons_interrupt_enabled)
|
||||
buttons_switch_to_input();
|
||||
else if (delay_between_runs[current_executor_id] != -1 && !buttons_interrupt_enabled)
|
||||
buttons_switch_to_interrupt();
|
||||
|
||||
executors[current_executor_id]();
|
||||
|
||||
if (delay_between_runs[current_executor_id] == -1) {
|
||||
WAIT_UNTIL_CB_PRESSED;
|
||||
HAL_Delay(150);
|
||||
GPIOD->BSRR = 0x1000;
|
||||
|
||||
WAIT_UNTIL_CB_RELEASED;
|
||||
HAL_Delay(150);
|
||||
GPIOD->BSRR = 0x1000 << 16;
|
||||
|
||||
if (cleanup_functions[current_executor_id])
|
||||
cleanup_functions[current_executor_id]();
|
||||
|
||||
switch_to_next_test();
|
||||
} else {
|
||||
HAL_Delay(delay_between_runs[current_executor_id]);
|
||||
}
|
||||
*/
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
}
|
||||
//}
|
||||
/* USER CODE END 3 */
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ void EXTI0_IRQHandler(void)
|
||||
{
|
||||
GPIOD->ODR = 0x1000;
|
||||
|
||||
//switch_to_next_test();
|
||||
switch_to_next_test();
|
||||
|
||||
for (int i = 300000; i > 0; i--) asm("nop");
|
||||
|
||||
@@ -217,7 +217,7 @@ void EXTI9_5_IRQHandler(void)
|
||||
{
|
||||
GPIOD->ODR = 0x1000;
|
||||
|
||||
//switch_to_next_test();
|
||||
switch_to_next_test();
|
||||
|
||||
for (int i = 300000; i > 0; i--) asm("nop");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user