Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c9b90a679e | |||
| ee3249beca | |||
| cc32a3092a | |||
| e65c4d612c | |||
| 7940c95b23 | |||
| 5bbbc9fe44 | |||
| 4c9c1ff2c8 | |||
| 0eb025d3d4 | |||
| 87eb642adc | |||
| 5c9846fce3 | |||
| 063ed8bb51 | |||
| 3ccc0ca0f3 | |||
| 9370ddbadd | |||
| ac75969758 | |||
| c74299dc0d | |||
| 8d41a30bff | |||
| 8b5bbd3e9a |
@@ -1,6 +1,6 @@
|
|||||||
#ifndef __EEPROM_24AA02E48
|
#ifndef __EEPROM_24AA02E48
|
||||||
#define __EEPROM_24AA02E48
|
#define __EEPROM_24AA02E48
|
||||||
|
|
||||||
void EEPROM_24AA02E48_run_test(void);
|
int EEPROM_24AA02E48_run_test(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#ifndef __CS43L22
|
#ifndef __CS43L22
|
||||||
#define __CS43L22
|
#define __CS43L22
|
||||||
|
|
||||||
void CS43L22_run_test(void);
|
int CS43L22_run_test(void);
|
||||||
void CS43L22_cleanup(void);
|
void CS43L22_cleanup(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+2
-2
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
extern ADC_HandleTypeDef hadc1;
|
extern ADC_HandleTypeDef hadc1;
|
||||||
|
|
||||||
void DNI_show_celsius(void);
|
int DNI_show_celsius(void);
|
||||||
void DNI_show_fahrenheit(void);
|
int DNI_show_fahrenheit(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
#ifndef __LIS302DL
|
#ifndef __LIS302DL
|
||||||
#define __LIS302DL
|
#define __LIS302DL
|
||||||
|
|
||||||
void LIS302DL_run_test(void);
|
int LIS302DL_run_test(void);
|
||||||
void LIS302DL_run_test_dynamic(void);
|
int LIS302DL_run_test_dynamic(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
#ifndef __LSM9DS1
|
#ifndef __LSM9DS1
|
||||||
#define __LSM9DS1
|
#define __LSM9DS1
|
||||||
|
|
||||||
void LSM9DS1_test_accel(void);
|
int LSM9DS1_test_accel(void);
|
||||||
void LSM9DS1_cleanup_accel(void);
|
void LSM9DS1_cleanup_accel(void);
|
||||||
void LSM9DS1_test_magnet(void);
|
int LSM9DS1_test_magnet(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#ifndef __MP45DT02
|
#ifndef __MP45DT02
|
||||||
#define __MP45DT02
|
#define __MP45DT02
|
||||||
|
|
||||||
void MP45DT02_run_test(void);
|
int MP45DT02_run_test(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#ifndef __PCA9685
|
#ifndef __PCA9685
|
||||||
#define __PCA9685
|
#define __PCA9685
|
||||||
|
|
||||||
void PCA9685_run_test(void);
|
int PCA9685_run_test(void);
|
||||||
void PCA9685_cleanup(void);
|
void PCA9685_cleanup(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#ifndef __SST25VF016B
|
#ifndef __SST25VF016B
|
||||||
#define __SST25VF016B
|
#define __SST25VF016B
|
||||||
|
|
||||||
void SST25VF016B_run_test(void);
|
int SST25VF016B_run_test(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
extern I2C_HandleTypeDef hi2c1;
|
extern I2C_HandleTypeDef hi2c1;
|
||||||
|
|
||||||
void EEPROM_24AA02E48_run_test(void)
|
int EEPROM_24AA02E48_run_test(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("24AA02E48 EEPROM");
|
display_write_data_seq("24AA02E48 EEPROM");
|
||||||
@@ -94,9 +94,13 @@ void EEPROM_24AA02E48_run_test(void)
|
|||||||
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;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
display_write_data_seq("OK ");
|
display_write_data_seq("OK ");
|
||||||
display_write_data_seq((char *) data_buffer);
|
display_write_data_seq((char *) data_buffer);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
extern I2C_HandleTypeDef hi2c1;
|
extern I2C_HandleTypeDef hi2c1;
|
||||||
|
|
||||||
void CS43L22_run_test(void)
|
int CS43L22_run_test(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("CS43L22 Audio");
|
display_write_data_seq("CS43L22 Audio");
|
||||||
@@ -57,9 +57,13 @@ void CS43L22_run_test(void)
|
|||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
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;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -73,7 +73,7 @@ static void DNI_print_fahrenheit(int temperature)
|
|||||||
DNI_print(temperature);
|
DNI_print(temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DNI_show_celsius(void)
|
int DNI_show_celsius(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
DISPLAY_SET_INCREMENT;
|
DISPLAY_SET_INCREMENT;
|
||||||
@@ -83,9 +83,11 @@ void DNI_show_celsius(void)
|
|||||||
uint32_t value = DNI_read();
|
uint32_t value = DNI_read();
|
||||||
int temp = DNI_convert_to_celsius(value);
|
int temp = DNI_convert_to_celsius(value);
|
||||||
DNI_print_celsius(temp);
|
DNI_print_celsius(temp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DNI_show_fahrenheit(void)
|
int DNI_show_fahrenheit(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
DISPLAY_SET_INCREMENT;
|
DISPLAY_SET_INCREMENT;
|
||||||
@@ -95,4 +97,6 @@ void DNI_show_fahrenheit(void)
|
|||||||
uint32_t value = DNI_read();
|
uint32_t value = DNI_read();
|
||||||
int temp = DNI_convert_to_fahrenheit(value);
|
int temp = DNI_convert_to_fahrenheit(value);
|
||||||
DNI_print_fahrenheit(temp);
|
DNI_print_fahrenheit(temp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-2
@@ -105,7 +105,7 @@ static void retrieve_data(size_t *err_count, uint8_t *data_xyz, char *postfix)
|
|||||||
FAILSAFE_POST_OP("RZ");
|
FAILSAFE_POST_OP("RZ");
|
||||||
}
|
}
|
||||||
|
|
||||||
void LIS302DL_run_test(void)
|
int LIS302DL_run_test(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("LIS302DL Accel");
|
display_write_data_seq("LIS302DL Accel");
|
||||||
@@ -129,13 +129,17 @@ void LIS302DL_run_test(void)
|
|||||||
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;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LIS302DL_run_test_dynamic(void)
|
int LIS302DL_run_test_dynamic(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("LIS302DL Accel D");
|
display_write_data_seq("LIS302DL Accel D");
|
||||||
@@ -159,8 +163,12 @@ void LIS302DL_run_test_dynamic(void)
|
|||||||
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;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-2
@@ -52,7 +52,7 @@ static void print_error_magnet(HAL_StatusTypeDef result, size_t *err_count, size
|
|||||||
print_error_message(result, err_count, t, prefix);
|
print_error_message(result, err_count, t, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LSM9DS1_test_accel(void)
|
int LSM9DS1_test_accel(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("LSM9DS1 Accel");
|
display_write_data_seq("LSM9DS1 Accel");
|
||||||
@@ -84,11 +84,15 @@ void LSM9DS1_test_accel(void)
|
|||||||
if (!err_count) {
|
if (!err_count) {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +103,7 @@ void LSM9DS1_cleanup_accel(void)
|
|||||||
HAL_I2C_Master_Transmit(&hi2c1, 0xD6, buffer, 2, 1000);
|
HAL_I2C_Master_Transmit(&hi2c1, 0xD6, buffer, 2, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LSM9DS1_test_magnet(void)
|
int LSM9DS1_test_magnet(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("LSM9DS1 Magnet");
|
display_write_data_seq("LSM9DS1 Magnet");
|
||||||
@@ -122,10 +126,14 @@ void LSM9DS1_test_magnet(void)
|
|||||||
if (!err_count) {
|
if (!err_count) {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
display_write_data_seq("OK");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
extern I2S_HandleTypeDef hi2s2;
|
extern I2S_HandleTypeDef hi2s2;
|
||||||
|
|
||||||
void MP45DT02_run_test(void)
|
int MP45DT02_run_test(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("MP45DT02 Mic");
|
display_write_data_seq("MP45DT02 Mic");
|
||||||
@@ -30,7 +30,7 @@ void MP45DT02_run_test(void)
|
|||||||
display_write_data_seq(" full 0 samples");
|
display_write_data_seq(" full 0 samples");
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ended up here, then no samples equaled to 1; that is not a good sign
|
// if ended up here, then no samples equaled to 1; that is not a good sign
|
||||||
@@ -50,4 +50,6 @@ void MP45DT02_run_test(void)
|
|||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 0);
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
display_write_data_seq("No good samples!");
|
display_write_data_seq("No good samples!");
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-2
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
extern I2C_HandleTypeDef hi2c1;
|
extern I2C_HandleTypeDef hi2c1;
|
||||||
|
|
||||||
void PCA9685_run_test(void)
|
int PCA9685_run_test(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("PCA9685 PWM");
|
display_write_data_seq("PCA9685 PWM");
|
||||||
@@ -40,6 +40,8 @@ void PCA9685_run_test(void)
|
|||||||
display_write_data_seq("/5 ");
|
display_write_data_seq("/5 ");
|
||||||
|
|
||||||
switch (op_result) {
|
switch (op_result) {
|
||||||
|
case HAL_OK:
|
||||||
|
break;
|
||||||
case HAL_ERROR:
|
case HAL_ERROR:
|
||||||
display_write_data_seq("ERROR");
|
display_write_data_seq("ERROR");
|
||||||
break;
|
break;
|
||||||
@@ -66,9 +68,13 @@ void PCA9685_run_test(void)
|
|||||||
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;
|
||||||
} else {
|
} else {
|
||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
display_write_data_seq("OK OUT ENABLED");
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-3
@@ -4,13 +4,14 @@
|
|||||||
|
|
||||||
extern SPI_HandleTypeDef hspi1;
|
extern SPI_HandleTypeDef hspi1;
|
||||||
|
|
||||||
void SST25VF016B_run_test(void)
|
int SST25VF016B_run_test(void)
|
||||||
{
|
{
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("SST25VF016B Flas");
|
display_write_data_seq("SST25VF016B Flas");
|
||||||
|
|
||||||
HAL_StatusTypeDef op_result;
|
HAL_StatusTypeDef op_result;
|
||||||
size_t err_count = 0;
|
size_t err_count = 0;
|
||||||
|
size_t chip_id_fault = 0;
|
||||||
|
|
||||||
uint8_t tx_buffer[8] = {0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
uint8_t tx_buffer[8] = {0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
uint8_t rx_buffer[9];
|
uint8_t rx_buffer[9];
|
||||||
@@ -46,8 +47,6 @@ void SST25VF016B_run_test(void)
|
|||||||
display_write_data_seq("TIMEOUT");
|
display_write_data_seq("TIMEOUT");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
HAL_Delay(2000);
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -62,6 +61,8 @@ void SST25VF016B_run_test(void)
|
|||||||
DISPLAY_SET_CURSOR(1, 1);
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
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;
|
||||||
} else {
|
} else {
|
||||||
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
|
||||||
@@ -70,6 +71,9 @@ void SST25VF016B_run_test(void)
|
|||||||
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");
|
||||||
|
|
||||||
|
chip_id_fault = 1;
|
||||||
|
|
||||||
goto write_retrieved_data;
|
goto write_retrieved_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,6 +85,9 @@ void SST25VF016B_run_test(void)
|
|||||||
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");
|
||||||
|
|
||||||
|
chip_id_fault = 1;
|
||||||
|
|
||||||
goto write_retrieved_data;
|
goto write_retrieved_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,4 +101,6 @@ void SST25VF016B_run_test(void)
|
|||||||
display_write_data_seq((char *) &(rx_buffer[4]));
|
display_write_data_seq((char *) &(rx_buffer[4]));
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_7, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_7, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
return (err_count || chip_id_fault);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,12 @@ static void display_write_data_byte_direct(uint8_t code)
|
|||||||
|
|
||||||
static void display_write_data_byte_framebuffer(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;
|
display_framebuffer[16*2*display_current_frame + des.cursor_offset] = (char) code;
|
||||||
des.cursor_offset += des.next ? -1 : 1;
|
des.cursor_offset += des.next ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+92
-168
@@ -46,6 +46,17 @@
|
|||||||
#define WAIT_UNTIL_CB_PRESSED while (!HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) && HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_8))
|
#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 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 */
|
/* USER CODE END PD */
|
||||||
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
/* Private macro -------------------------------------------------------------*/
|
||||||
@@ -68,22 +79,19 @@ extern size_t display_current_frame;
|
|||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
void ((*executors[])(void)) = {
|
static const int ((*executors[])(void)) = {
|
||||||
DNI_show_celsius,
|
DNI_show_celsius,
|
||||||
DNI_show_fahrenheit,
|
|
||||||
PCA9685_run_test,
|
PCA9685_run_test,
|
||||||
EEPROM_24AA02E48_run_test,
|
EEPROM_24AA02E48_run_test,
|
||||||
CS43L22_run_test,
|
CS43L22_run_test,
|
||||||
SST25VF016B_run_test,
|
SST25VF016B_run_test,
|
||||||
LIS302DL_run_test,
|
LIS302DL_run_test,
|
||||||
LIS302DL_run_test_dynamic,
|
|
||||||
MP45DT02_run_test,
|
MP45DT02_run_test,
|
||||||
LSM9DS1_test_accel,
|
LSM9DS1_test_accel,
|
||||||
LSM9DS1_test_magnet
|
LSM9DS1_test_magnet
|
||||||
};
|
};
|
||||||
|
|
||||||
void ((*cleanup_functions[])(void)) = {
|
static const void ((*cleanup_functions[])(void)) = {
|
||||||
NULL,
|
|
||||||
NULL,
|
NULL,
|
||||||
PCA9685_cleanup,
|
PCA9685_cleanup,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -91,29 +99,10 @@ void ((*cleanup_functions[])(void)) = {
|
|||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
|
||||||
LSM9DS1_cleanup_accel,
|
LSM9DS1_cleanup_accel,
|
||||||
NULL
|
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 */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
@@ -131,67 +120,7 @@ static void MX_I2S2_Init(void);
|
|||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
void switch_to_next_test(void)
|
static void button_init_and_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
|
// letting the buttons be tested
|
||||||
display_write_data_seq("Fill any bar:");
|
display_write_data_seq("Fill any bar:");
|
||||||
@@ -201,11 +130,11 @@ void button_init_and_test(void)
|
|||||||
size_t pressed_elements;
|
size_t pressed_elements;
|
||||||
|
|
||||||
uint32_t sw_button_locations[5][2] = {
|
uint32_t sw_button_locations[5][2] = {
|
||||||
{GPIOC, GPIO_PIN_11},
|
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_11},
|
||||||
{GPIOA, GPIO_PIN_15},
|
{(uint32_t) GPIOA, (uint32_t) GPIO_PIN_15},
|
||||||
{GPIOC, GPIO_PIN_9},
|
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_9},
|
||||||
{GPIOC, GPIO_PIN_6},
|
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_6},
|
||||||
{GPIOC, GPIO_PIN_8}
|
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_8}
|
||||||
};
|
};
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -226,7 +155,7 @@ void button_init_and_test(void)
|
|||||||
for (size_t i = 0; i < 5; i++) {
|
for (size_t i = 0; i < 5; i++) {
|
||||||
pressed_elements >>= 1;
|
pressed_elements >>= 1;
|
||||||
|
|
||||||
size_t input = !HAL_GPIO_ReadPin(sw_button_locations[i][0], sw_button_locations[i][1]);
|
size_t input = !HAL_GPIO_ReadPin((GPIO_TypeDef *) sw_button_locations[i][0], sw_button_locations[i][1]);
|
||||||
|
|
||||||
if (input) {
|
if (input) {
|
||||||
pressed_elements |= 0x20;
|
pressed_elements |= 0x20;
|
||||||
@@ -243,16 +172,16 @@ void button_init_and_test(void)
|
|||||||
display_write_data_seq("Release buttons");
|
display_write_data_seq("Release buttons");
|
||||||
|
|
||||||
GPIOD->ODR = 0x1000;
|
GPIOD->ODR = 0x1000;
|
||||||
HAL_Delay(500);
|
HAL_Delay(300);
|
||||||
GPIOD->ODR = 0x2000;
|
GPIOD->ODR = 0x2000;
|
||||||
HAL_Delay(500);
|
HAL_Delay(300);
|
||||||
GPIOD->ODR = 0x4000;
|
GPIOD->ODR = 0x4000;
|
||||||
HAL_Delay(500);
|
HAL_Delay(300);
|
||||||
GPIOD->ODR = 0x8000;
|
GPIOD->ODR = 0x8000;
|
||||||
HAL_Delay(500);
|
HAL_Delay(300);
|
||||||
|
|
||||||
// waiting for control buttons to be released
|
// waiting for all buttons to be released
|
||||||
WAIT_UNTIL_CB_RELEASED;
|
WAIT_UNTIL_ALL_BUTTONS_RELEASED;
|
||||||
GPIOD->ODR = 0x0000;
|
GPIOD->ODR = 0x0000;
|
||||||
HAL_Delay(200);
|
HAL_Delay(200);
|
||||||
}
|
}
|
||||||
@@ -294,7 +223,6 @@ int main(void)
|
|||||||
MX_TIM2_Init();
|
MX_TIM2_Init();
|
||||||
MX_I2S2_Init();
|
MX_I2S2_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
buttons_interrupt_enabled = 0;
|
|
||||||
|
|
||||||
HAL_TIM_Base_Start(&htim2);
|
HAL_TIM_Base_Start(&htim2);
|
||||||
TIM2->CNT = 0;
|
TIM2->CNT = 0;
|
||||||
@@ -307,99 +235,95 @@ int main(void)
|
|||||||
button_init_and_test();
|
button_init_and_test();
|
||||||
|
|
||||||
// perform all tests
|
// perform all tests
|
||||||
display_to_framebuffer();
|
size_t successful_tests = 0;
|
||||||
|
size_t failed_tests = 0;
|
||||||
|
|
||||||
for (display_current_frame = 0; display_current_frame < 11; display_current_frame++)
|
for (display_current_frame = 1; display_current_frame < LEN(executors)+1; display_current_frame++)
|
||||||
{
|
{
|
||||||
executors[display_current_frame]();
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("Testing...");
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 2);
|
||||||
|
display_write_data_seq("P:");
|
||||||
|
display_write_data_byte('0' + (successful_tests / 10) % 10);
|
||||||
|
display_write_data_byte('0' + (successful_tests) % 10);
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 10);
|
||||||
|
display_write_data_seq("F:");
|
||||||
|
display_write_data_byte('0' + (failed_tests / 10) % 10);
|
||||||
|
display_write_data_byte('0' + (failed_tests) % 10);
|
||||||
|
|
||||||
|
display_to_framebuffer();
|
||||||
|
|
||||||
|
// test
|
||||||
|
if (executors[display_current_frame-1]())
|
||||||
|
failed_tests++;
|
||||||
|
else
|
||||||
|
successful_tests++;
|
||||||
|
|
||||||
|
// cleanup (if required)
|
||||||
|
if (cleanup_functions[display_current_frame-1])
|
||||||
|
cleanup_functions[display_current_frame-1]();
|
||||||
|
|
||||||
|
display_to_direct();
|
||||||
}
|
}
|
||||||
|
|
||||||
display_to_direct();
|
// render final result to first framebuffer
|
||||||
|
display_to_framebuffer();
|
||||||
display_current_frame = 0;
|
display_current_frame = 0;
|
||||||
|
|
||||||
if (buttons_interrupt_enabled)
|
DISPLAY_CLEAR;
|
||||||
buttons_switch_to_input();
|
display_write_data_seq("All tests done!");
|
||||||
|
|
||||||
while (1) {
|
DISPLAY_SET_CURSOR(1, 2);
|
||||||
// wait until all buttons are released
|
display_write_data_seq("P:");
|
||||||
while (
|
display_write_data_byte('0' + (successful_tests / 10) % 10);
|
||||||
(GPIOA->IDR & GPIO_PIN_0) ||
|
display_write_data_byte('0' + (successful_tests) % 10);
|
||||||
!(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);
|
DISPLAY_SET_CURSOR(1, 10);
|
||||||
|
display_write_data_seq("F:");
|
||||||
|
display_write_data_byte('0' + (failed_tests / 10) % 10);
|
||||||
|
display_write_data_byte('0' + (failed_tests) % 10);
|
||||||
|
|
||||||
while (1) {
|
display_to_direct();
|
||||||
// go to next report
|
|
||||||
if (
|
|
||||||
(GPIOA->IDR & GPIO_PIN_0) ||
|
|
||||||
!(GPIOC->IDR & GPIO_PIN_11) ||
|
|
||||||
!(GPIOC->IDR & GPIO_PIN_8)
|
|
||||||
) {
|
|
||||||
display_current_frame += 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// go to previous report
|
|
||||||
else if (
|
|
||||||
!(GPIOC->IDR & GPIO_PIN_9) ||
|
|
||||||
!(GPIOC->IDR & GPIO_PIN_6)
|
|
||||||
) {
|
|
||||||
display_current_frame -= 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// execute this test live
|
|
||||||
else if (
|
|
||||||
!(GPIOA->IDR & GPIO_PIN_15)
|
|
||||||
) {
|
|
||||||
// not implemented
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
|
while (1) {
|
||||||
|
WAIT_UNTIL_ALL_BUTTONS_RELEASED;
|
||||||
|
|
||||||
/*
|
display_load(display_current_frame);
|
||||||
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]();
|
while (1) {
|
||||||
|
// go to next report
|
||||||
|
if (UB || SWT1 || SWT5) {
|
||||||
|
display_current_frame += 1;
|
||||||
|
display_current_frame %= LEN(executors)+1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (delay_between_runs[current_executor_id] == -1) {
|
// go to previous report
|
||||||
WAIT_UNTIL_CB_PRESSED;
|
else if (SWT3 || SWT4) {
|
||||||
HAL_Delay(150);
|
display_current_frame -= 1;
|
||||||
GPIOD->BSRR = 0x1000;
|
|
||||||
|
|
||||||
WAIT_UNTIL_CB_RELEASED;
|
if ((int) display_current_frame == -1)
|
||||||
HAL_Delay(150);
|
display_current_frame = LEN(executors);
|
||||||
GPIOD->BSRR = 0x1000 << 16;
|
|
||||||
|
|
||||||
if (cleanup_functions[current_executor_id])
|
break;
|
||||||
cleanup_functions[current_executor_id]();
|
}
|
||||||
|
|
||||||
switch_to_next_test();
|
// return to summary frame
|
||||||
} else {
|
else if (SWT2) {
|
||||||
HAL_Delay(delay_between_runs[current_executor_id]);
|
display_current_frame = 0;
|
||||||
}
|
break;
|
||||||
*/
|
}
|
||||||
|
}
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
//}
|
}
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ void EXTI0_IRQHandler(void)
|
|||||||
{
|
{
|
||||||
GPIOD->ODR = 0x1000;
|
GPIOD->ODR = 0x1000;
|
||||||
|
|
||||||
switch_to_next_test();
|
//switch_to_next_test();
|
||||||
|
|
||||||
for (int i = 300000; i > 0; i--) asm("nop");
|
for (int i = 300000; i > 0; i--) asm("nop");
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ void EXTI9_5_IRQHandler(void)
|
|||||||
{
|
{
|
||||||
GPIOD->ODR = 0x1000;
|
GPIOD->ODR = 0x1000;
|
||||||
|
|
||||||
switch_to_next_test();
|
//switch_to_next_test();
|
||||||
|
|
||||||
for (int i = 300000; i > 0; i--) asm("nop");
|
for (int i = 300000; i > 0; i--) asm("nop");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user