dev8051:code8051
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| dev8051:code8051 [2024/11/11 11:50] – created azman | dev8051:code8051 [2024/11/12 10:29] (current) – [Code: relay] azman | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| ++++ Testing IR module and HC-SR04 ultrasonic sensor module. | | ++++ Testing IR module and HC-SR04 ultrasonic sensor module. | | ||
| - | <file c test0.c> | + | <file c nmk322_test0.c> |
| / | / | ||
| #include " | #include " | ||
| Line 229: | Line 229: | ||
| ++++ Testing Base Kit (202425s1). | | ++++ Testing Base Kit (202425s1). | | ||
| - | <file c basetest.c> | + | <file c nmk322_basetest.c> |
| / | / | ||
| /* override default tick values */ | /* override default tick values */ | ||
| Line 256: | Line 256: | ||
| P1 = seg7[loop] ^ mask; | P1 = seg7[loop] ^ mask; | ||
| timer_tick00(); | timer_tick00(); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | / | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | ++++ Testing RFID (FRC522) and OLED (ssd1306). | | ||
| + | <file c nmk322_test2.c> | ||
| + | / | ||
| + | #include " | ||
| + | #include " | ||
| + | #include " | ||
| + | #include " | ||
| + | #define APPTITLE " | ||
| + | / | ||
| + | void main(void) { | ||
| + | __xdata cstr_t buff; /* default: 64-bytes long */ | ||
| + | unsigned char temp, stat, loop, size; | ||
| + | unsigned char pdat[FRC522_MAX_RXSIZE], | ||
| + | /** initialize */ | ||
| + | cstr_init(& | ||
| + | uart_init(); | ||
| + | i2c_init(); | ||
| + | oled1306_init(); | ||
| + | spi_init(); | ||
| + | atqa = reqa; | ||
| + | /* initialize mf contactless card reader */ | ||
| + | /** say something... */ | ||
| + | uart_puts(" | ||
| + | uart_puts(APPTITLE); | ||
| + | uart_puts(" | ||
| + | oled1306_puts(APPTITLE); | ||
| + | temp = frc522_init(); | ||
| + | if (!temp||temp==0xff) { | ||
| + | uart_puts(" | ||
| + | hang(); | ||
| + | } | ||
| + | uart_puts(" | ||
| + | uart_send_hexbyte(temp); | ||
| + | uart_puts(" | ||
| + | /** main loop */ | ||
| + | while (1) { | ||
| + | stat = frc522_scan(pdat,& | ||
| + | if (stat==FRC522_OK) { | ||
| + | uart_puts("## | ||
| + | uart_send_hexbyte(stat); | ||
| + | uart_puts(" | ||
| + | uart_send_hexbyte(reqa[0]); | ||
| + | uart_puts("," | ||
| + | uart_send_hexbyte(reqa[1]); | ||
| + | uart_puts(" | ||
| + | cstr_null(& | ||
| + | for (loop=0; | ||
| + | uart_send(' | ||
| + | uart_send_hexbyte(pdat[loop]); | ||
| + | cstr_append_hexbyte(& | ||
| + | uart_send(' | ||
| + | } | ||
| + | uart_send(' | ||
| + | oled1306_set_cursor(2, | ||
| + | oled1306_puts("# | ||
| + | oled1306_puts(buff.buff); | ||
| + | loop_delay(3000); | ||
| + | oled1306_clear_row(2); | ||
| + | } | ||
| + | else if (stat!=FRC522_ERROR_NO_TAG&& | ||
| + | uart_puts(" | ||
| + | uart_send_hexbyte(stat); | ||
| + | uart_puts(" | ||
| + | for (loop=0; | ||
| + | uart_send(' | ||
| + | uart_send_hexbyte(pdat[loop]); | ||
| + | uart_send(' | ||
| + | } | ||
| + | uart_send(' | ||
| + | oled1306_set_cursor(3, | ||
| + | oled1306_puts(" | ||
| + | loop_delay(3000); | ||
| + | oled1306_clear_row(3); | ||
| } | } | ||
| } | } | ||
| Line 265: | Line 345: | ||
| ===== Code: relay ===== | ===== Code: relay ===== | ||
| - | ++++ Testing basic relay. | + | Testing basic relay. |
| <file c relay.c> | <file c relay.c> | ||
| / | / | ||
| Line 295: | Line 375: | ||
| / | / | ||
| </ | </ | ||
| - | ++++ | ||
| ===== Code: gtuc51 ===== | ===== Code: gtuc51 ===== | ||
dev8051/code8051.1731297017.txt.gz · Last modified: by azman
