Skip to content

Commit 34e1c6c

Browse files
fix(Examples): Fixed bug in FaceId RISC-V example (#807)
Co-authored-by: Jake Carter <[email protected]> Co-authored-by: Jake Carter <[email protected]>
1 parent 06d693e commit 34e1c6c

File tree

13 files changed

+44
-39
lines changed

13 files changed

+44
-39
lines changed

Examples/MAX78000/CNN/asl_demo/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ Universal instructions on building, flashing, and debugging this project can be
2525
* This project comes pre-configured for the MAX78000EVKIT. See [Board Support Packages](https://analog-devices-msdk.github.io/msdk/USERGUIDE/#board-support-packages) in the UG for instructions on changing the target board.
2626

2727
* This project supports output to a TFT display.
28-
* For the MAX78000EVKIT, the TFT display is **enabled** by default. It can be _disabled_ by commenting out `#define ENABLE_TFT` in [example_config.h](example_config.h).
28+
* For the MAX78000EVKIT, the TFT display is **enabled** by default. It can be _disabled_ by commenting out `#define TFT_ENABLE` in [example_config.h](example_config.h).
2929

3030
```C
3131
#ifdef BOARD_EVKIT_V1
32-
// #define ENABLE_TFT
32+
// #define TFT_ENABLE
3333
#include "bitmap.h"
3434
#include "tft_ssd2119.h"
3535
#endif
3636
```
3737

38-
* For the MAX78000FTHR, the TFT display is **disabled** by default. The TFT display is not supplied with the MAX78000 Feather board. The compatible 2.4'' TFT FeatherWing display can be ordered [here](https://learn.adafruit.com/adafruit-2-4-tft-touch-screen-featherwing). To _enable_ the display code, uncomment `#define ENABLE_TFT` in [example_config.h](example_config.h)
38+
* For the MAX78000FTHR, the TFT display is **disabled** by default. The TFT display is not supplied with the MAX78000 Feather board. The compatible 2.4'' TFT FeatherWing display can be ordered [here](https://learn.adafruit.com/adafruit-2-4-tft-touch-screen-featherwing). To _enable_ the display code, uncomment `#define TFT_ENABLE` in [example_config.h](example_config.h)
3939

4040
```C
4141
#ifdef BOARD_FTHR_REVA
42-
// #define ENABLE_TFT
42+
// #define TFT_ENABLE
4343
#include "tft_ili9341.h"
4444
#endif
4545
```

Examples/MAX78000/CNN/asl_demo/example_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
#define CONFIG_H
33

44
#ifdef BOARD_EVKIT_V1
5-
#define ENABLE_TFT
5+
#define TFT_ENABLE
66
#include "bitmap.h"
77
#include "tft_ssd2119.h"
88
#endif
99

1010
#ifdef BOARD_FTHR_REVA
11-
// #define ENABLE_TFT
11+
// #define TFT_ENABLE
1212
#include "tft_ili9341.h"
1313
#endif
1414

Examples/MAX78000/CNN/digit-detection-demo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Universal instructions on building, flashing, and debugging this project can be
3737
#endif
3838
```
3939

40-
* For the MAX78000FTHR, the TFT display is **disabled** by default. The TFT display is not supplied with the MAX78000 Feather board. The compatible 2.4'' TFT FeatherWing display can be ordered [here](https://learn.adafruit.com/adafruit-2-4-tft-touch-screen-featherwing). To _enable_ the display code, uncomment `#define ENABLE_TFT` in [example_config.h](example_config.h)
40+
* For the MAX78000FTHR, the TFT display is **disabled** by default. The TFT display is not supplied with the MAX78000 Feather board. The compatible 2.4'' TFT FeatherWing display can be ordered [here](https://learn.adafruit.com/adafruit-2-4-tft-touch-screen-featherwing). To _enable_ the display code, uncomment `#define TFT_ENABLE` in [example_config.h](example_config.h)
4141
4242
```C
4343
#ifdef BOARD_FTHR_REVA

Examples/MAX78000/CNN/faceid_evkit-riscv/include/faceID.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
#define IMAGE_READY 3
6666
#define RESULT_READY 4
6767

68-
#define CAPTURE_X 70
68+
#define CAPTURE_X 50
6969
#define CAPTURE_Y 290
7070
#define SKIP_X 60
7171
#define SKIP_Y 290

Examples/MAX78000/CNN/faceid_evkit-riscv/main.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static void screen_faceID(void)
197197
#ifdef BOARD_EVKIT_V1
198198
MXC_TFT_ShowImage(BACK_X, BACK_Y, left_arrow_bmp); // back button icon
199199
#endif
200-
MXC_TFT_PrintFont(98, 5, font, &screen_msg[0], NULL); // FACEID DEMO
200+
MXC_TFT_PrintFont(50, 5, font, &screen_msg[0], NULL); // FACEID DEMO
201201
MXC_TFT_PrintFont(12, 240, font, &screen_msg[1], NULL); // Process Time:
202202
// texts
203203
#ifdef TS_ENABLE
@@ -212,7 +212,7 @@ static int init(void)
212212
uint8_t *raw;
213213
uint32_t w, h;
214214
area_t area1 = { 150, 240, 50, 30 };
215-
area_t area2 = { 60, 290, 180, 30 };
215+
area_t area2 = { 50, 290, 180, 30 };
216216

217217
screen_faceID();
218218

@@ -402,7 +402,7 @@ int main(void)
402402
MXC_RTC_Start();
403403

404404
#ifdef TFT_ENABLE
405-
405+
printf("TFT init\n");
406406
#ifdef BOARD_EVKIT_V1
407407
/* Initialize TFT display */
408408
MXC_TFT_Init();
@@ -446,6 +446,7 @@ int main(void)
446446
NVIC_EnableIRQ(RISCV_IRQn);
447447
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_CPU1); // Enable RISC-V clock
448448

449+
#ifdef LP_MODE_ENABLE
449450
// Get ticks based off of milliseconds
450451
MXC_WUT_GetTicks(LP_TIME, MXC_WUT_UNIT_MILLISEC, &ticks);
451452

@@ -462,14 +463,13 @@ int main(void)
462463
MXC_LP_EnableWUTAlarmWakeup();
463464

464465
NVIC_EnableIRQ(WUT_IRQn);
466+
#endif
465467

466468
#ifndef TFT_ENABLE
467469
int i;
468470

469471
for (i = 0; i < (1 << 27); i++) {}
470472
// Let debugger interrupt if needed
471-
472-
__WFI(); // ARM sleeps
473473
#endif
474474

475475
#ifndef TS_ENABLE
@@ -485,8 +485,10 @@ int main(void)
485485
#endif
486486

487487
if (key > 0) {
488+
#ifdef LP_MODE_ENABLE
488489
// Start Wakeup Timer in case RISC-V sleeps
489490
MXC_WUT_Enable();
491+
#endif
490492
arm_mail_box[0] = START_FACEID;
491493
state->prcss_key(key);
492494
}

Examples/MAX78000/CNN/faceid_evkit-riscv/main_riscv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ int main(void)
134134
/* Enable camera power */
135135
Camera_Power(POWER_ON);
136136
MXC_Delay(300000);
137-
PR_DEBUG("\n\nFaceID Feather Demo\n");
137+
PR_DEBUG("FaceID Feather Demo\n");
138138
#else
139-
PR_DEBUG("\n\nFaceID Evkit Demo\n");
139+
PR_DEBUG("FaceID Evkit Demo\n");
140140
#endif
141141

142142
// Initialize the camera driver.

Examples/MAX78000/CNN/faceid_evkit-riscv/project.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ endif
2323
# Place build files specific to FTHR_RevA here.
2424
ifeq "$(BOARD)" "FTHR_RevA"
2525
# Only Enable if 2.4" TFT is connected to Feather
26-
#PROJ_CFLAGS+=-DENABLE_TFT
26+
#PROJ_CFLAGS+=-DTFT_ENABLE
2727
FONTS = LiberationSans16x16
2828
endif
2929

Examples/MAX78000/CNN/kws20_demo-riscv/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ To compile code with enabled TFT feature use following setting in project.mk:
196196

197197
```bash
198198
ifeq "$(BOARD)" "FTHR_RevA"
199-
PROJ_CFLAGS += -DENABLE_TFT
199+
PROJ_CFLAGS += -DTFT_ENABLE
200200
endif
201201
```
202202

Examples/MAX78000/CNN/kws20_demo-riscv/main.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
extern volatile void const *__FlashStart_; // Defined in linker file
7878
char buff[TFT_BUFF_SIZE];
7979

80-
#ifdef ENABLE_TFT
80+
#ifdef TFT_ENABLE
8181
void TFT_Intro(void);
8282
void TFT_Print(char *str, int x, int y, int font, int length);
8383
void TFT_End(uint16_t words);
@@ -127,7 +127,7 @@ int main(void)
127127

128128
printf("Analog Devices \nKeyword Spotting Demo\nVer. %s \n", VERSION);
129129

130-
#ifdef ENABLE_TFT
130+
#ifdef TFT_ENABLE
131131
MXC_Delay(500000);
132132
printf("\n*** Init TFT ***\n");
133133
#ifdef BOARD_EVKIT_V1
@@ -169,9 +169,11 @@ int main(void)
169169
// printf("mailbox ARM: %x\n",&mail_box[0]);
170170

171171
while (1) {
172-
int16_t max = 0; // soft_max output is 0->32767
173-
int16_t max_index = -1;
172+
#ifdef TFT_ENABLE
174173
int i = 0;
174+
int16_t max = 0; // soft_max output is 0->32767
175+
#endif
176+
int16_t max_index;
175177

176178
//LED_On(0);
177179
__WFI(); // Let RISC-V run
@@ -181,7 +183,7 @@ int main(void)
181183

182184
/* is there anything in the mail box? */
183185
if (mail_box[MAILBOX_SIZE - 1]) {
184-
#ifdef ENABLE_TFT
186+
#ifdef TFT_ENABLE
185187
// update TFT message
186188
MXC_TFT_ClearScreen();
187189
memset(buff, 32, TFT_BUFF_SIZE);
@@ -218,7 +220,7 @@ int main(void)
218220
}
219221

220222
/************************************************************************************/
221-
#ifdef ENABLE_TFT
223+
#ifdef TFT_ENABLE
222224
void TFT_Intro(void)
223225
{
224226
char buff[TFT_BUFF_SIZE];

Examples/MAX78000/CNN/kws20_demo-riscv/project.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@
99

1010
ifeq "$(BOARD)" ""
1111
BOARD = EvKit_V1
12+
#BOARD=FTHR_RevA
1213
endif
1314

1415
# Place build files specific to EvKit_V1 here.
1516
ifeq "$(BOARD)" "EvKit_V1"
16-
PROJ_CFLAGS+=-DENABLE_TFT
17+
PROJ_CFLAGS+=-DTFT_ENABLE
1718
endif
1819

1920
# Place build files specific to FTHR_RevA here.
2021
ifeq "$(BOARD)" "FTHR_RevA"
2122
# Only Enable if 2.4" TFT is connected to Feather
22-
# PROJ_CFLAGS+=-DENABLE_TFT
23+
#PROJ_CFLAGS+=-DTFT_ENABLE
2324
FONTS = LiberationSans16x16
2425
endif
2526

Examples/MAX78000/CNN/kws20_demo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ When option `-a` is used, each file is converted to a .wav file once and subsequ
365365
366366
***Note 1: When `SEND_MIC_OUT_SDCARD` is selected, the Wake-Up Timer (WUT) is disabled.***
367367
368-
***Note 2: When `SEND_MIC_OUT_SDCARD` is selected, the `ENABLE_TFT` is disabled regardless of make options.***
368+
***Note 2: When `SEND_MIC_OUT_SDCARD` is selected, the `TFT_ENABLE` is disabled regardless of make options.***
369369
370370
### Sending Sound Snippets to serial
371371

Examples/MAX78000/CNN/kws20_demo/main.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@
109109
#ifdef SEND_MIC_OUT_SDCARD
110110
#undef WUT_ENABLE
111111
#warning !!! Disabling WUT_ENABLE option when SD card is enabled !!!
112-
#ifdef ENABLE_TFT
113-
#undef ENABLE_TFT
112+
#ifdef TFT_ENABLE
113+
#undef TFT_ENABLE
114114
#warning !!! TFT cannot be used when SD card is enabled !!!
115115
#endif
116116
#endif
117117

118-
#ifdef ENABLE_TFT
118+
#ifdef TFT_ENABLE
119119
#define DISPLAY_AUDIO // displays audio waveform on TFT
120120
#endif
121121

@@ -266,7 +266,7 @@ uint8_t check_inference(q15_t *ml_soft, int32_t *ml_data, int16_t *out_class, do
266266
void I2SInit();
267267
void HPF_init(void);
268268
int16_t HPF(int16_t input);
269-
#ifdef ENABLE_TFT
269+
#ifdef TFT_ENABLE
270270
void TFT_Intro(void);
271271
void TFT_Print(char *str, int x, int y, int font, int length);
272272
void TFT_End(uint16_t words);
@@ -280,7 +280,7 @@ int image_bitmap = (int)&img_1_rgb565[0];
280280
int font_1 = (int)&Liberation_Sans16x16[0];
281281
int font_2 = (int)&Liberation_Sans16x16[0];
282282
#endif
283-
#endif //#ifdef ENABLE_TFT
283+
#endif //#ifdef TFT_ENABLE
284284

285285
int32_t tot_usec = -100000;
286286
#ifdef WUT_ENABLE
@@ -466,7 +466,7 @@ int main(void)
466466
I2SInit();
467467
#endif
468468

469-
#ifdef ENABLE_TFT
469+
#ifdef TFT_ENABLE
470470
MXC_Delay(500000);
471471
PR_DEBUG("\n*** Init TFT ***\n");
472472
#ifdef BOARD_EVKIT_V1
@@ -495,7 +495,7 @@ int main(void)
495495
#else
496496

497497
MXC_Delay(SEC(2)); // wait for debugger to connect
498-
#endif // #ifdef ENABLE_TFT
498+
#endif // #ifdef TFT_ENABLE
499499

500500
PR_INFO("\n*** READY ***\n");
501501
#ifdef WUT_ENABLE
@@ -918,7 +918,7 @@ int main(void)
918918
LED_Off(LED2);
919919
PR_DEBUG("Total Samples:%d, Total Words: %d \n", sampleCounter, wordCounter);
920920

921-
#ifdef ENABLE_TFT
921+
#ifdef TFT_ENABLE
922922
TFT_End(wordCounter);
923923
#endif
924924

@@ -979,7 +979,7 @@ void I2SInit()
979979
/* **************************************************************************** */
980980
uint8_t check_inference(q15_t *ml_soft, int32_t *ml_data, int16_t *out_class, double *out_prob)
981981
{
982-
#ifdef ENABLE_TFT
982+
#ifdef TFT_ENABLE
983983
char buff[TFT_BUFF_SIZE];
984984
#endif
985985
int32_t temp[NUM_OUTPUTS];
@@ -1004,7 +1004,7 @@ uint8_t check_inference(q15_t *ml_soft, int32_t *ml_data, int16_t *out_class, do
10041004
if (top == 0) {
10051005
*out_class = max_index;
10061006
*out_prob = 100.0 * max / 32768.0;
1007-
#ifndef ENABLE_TFT
1007+
#ifndef TFT_ENABLE
10081008
break;
10091009
}
10101010

@@ -1317,7 +1317,7 @@ int16_t HPF(int16_t input)
13171317
}
13181318

13191319
/************************************************************************************/
1320-
#ifdef ENABLE_TFT
1320+
#ifdef TFT_ENABLE
13211321
void TFT_Intro(void)
13221322
{
13231323
char buff[TFT_BUFF_SIZE];

Examples/MAX78000/CNN/kws20_demo/project.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ MXC_OPTIMIZE_CFLAGS = -O2
2121

2222
# Place build files specific to EvKit_V1 here.
2323
ifeq "$(BOARD)" "EvKit_V1"
24-
PROJ_CFLAGS+=-DENABLE_TFT
24+
PROJ_CFLAGS+=-DTFT_ENABLE
2525
IPATH += TFT/evkit/
2626
VPATH += TFT/evkit/
2727
endif
@@ -32,7 +32,7 @@ endif
3232
# Place build files specific to FTHR_RevA here.
3333
ifeq "$(BOARD)" "FTHR_RevA"
3434
# Only Enable if 2.4" TFT is connected to Feather
35-
#PROJ_CFLAGS+=-DENABLE_TFT
35+
#PROJ_CFLAGS+=-DTFT_ENABLE
3636

3737
# If enabled, it saves out the Mic samples used for inference to SDCARD
3838
# Note that if both SDCARD and TFT are enabled, the TFT will be disabled to avoid SPI driver conflict.

0 commit comments

Comments
 (0)