This commit is contained in:
2024-10-10 19:45:45 +06:00
parent df9b2445bd
commit 8d0606462d
4 changed files with 51 additions and 24 deletions

View File

@@ -26,17 +26,46 @@ Resolving domain name "hye.su"...
> Partial DNS message: 11 23 81 82 00 01 00 00 00 00 00 00 03 68 79 65 00 00 00 02 73 > Partial DNS message: 11 23 81 82 00 01 00 00 00 00 00 00 03 68 79 65 00 00 00 02 73
DNS_run() failed, res = 0 DNS_run() failed, res = 0
``` ```
w/ ch32v003fun w/ ch32v003fun
> Partial DNS message: `11 23 81 82 00 01 00 00 00 00 00 00 03 68 79 65 00 00 00 02 73` > Partial DNS message: `11 23 81 82 00 01 00 00 00 00 00 00 03 68 79 65 00 00 00 02 73`
**DNS_run() failed, res = 0** > **DNS_run() failed, res = 0**
w/ WCH HAL (none-os).. I get a full response w/ WCH HAL (none-os).. I get a full response
> Receive DNS message from 192.168.102.1(53). len = 56 > Receive DNS message from 192.168.102.1(53). len = 56
> Partial DNS message: `11 23 81 80 00 01 00 02 00 00 00 00 03 68 79 65 02 73 75 00 00 01 00 01 C0 0C 00 01 00 01 00 00 01 2C 00 04 68 15 33 7F C0 0C 00 01 00 01 00 00 01 2C 00 04 AC 43 B4 9A ` > Partial DNS message: `11 23 81 80 00 01 00 02 00 00 00 00 03 68 79 65 02 73 75 00 00 01 00 01 C0 0C 00 01 00 01 00 00 01 2C 00 04 68 15 33 7F C0 0C 00 01 00 01 00 00 01 2C 00 04 AC 43 B4 9A `
Result: 172.67.180.154 > Result: 172.67.180.154
`RCC_CTLR`, GPIO Registers, `SPIx_CTLR1` registers are identical `RCC_CTLR`, GPIO Registers, `SPIx_CTLR1` registers are identical
## LA
### ch32v003fun
![ch32v003fun](notes/2024-10-10-191033_1876x540_scrot.png)
```
00 00 34 11 27 01 00 00 01 00 00 00 00 00 00 03 68 79 65 00 00 00 02 73 75 00 00 00 00 01 00 01
```
- 32 bytes long
- (Post `68 79 65`): `00 00 00 02 73 75 00 00 00 00 01 00 01`
### none-os
![none-os](notes/2024-10-10-191043_1891x525_scrot.png)
```
00 00 34 11 27 01 00 00 01 00 00 00 00 00 00 03 68 79 65 02 73 75 00 00 01 00 01
```
- 27 bytes long
- (Post `68 79 65`): `02 73 75 00 00 01 00 01`
## none-os
```c ```c
// Initialize GPIO for W5500 CS // Initialize GPIO for W5500 CS
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

View File

@@ -74,8 +74,8 @@ void init_spi(void) {
SPI1->CTLR1 = 0; SPI1->CTLR1 = 0;
// set prescaler // set prescaler
// 001: FPCLK/4; // 011: FPCLK/16
SPI1->CTLR1 = (SPI1->CTLR1 & ~SPI_CTLR1_BR) | (0x1 << 3); SPI1->CTLR1 = (SPI1->CTLR1 & ~SPI_CTLR1_BR) | (0x3 << 3);
// set clock polarity and phase // set clock polarity and phase
SPI1->CTLR1 |= (SPI_CPOL_Low | SPI_CPHA_1Edge); SPI1->CTLR1 |= (SPI_CPOL_Low | SPI_CPHA_1Edge);
@@ -174,25 +174,23 @@ int main(void) {
printf("Calling DNS_init()...\r\n"); printf("Calling DNS_init()...\r\n");
DNS_init(DNS_SOCKET, dns_buffer); DNS_init(DNS_SOCKET, dns_buffer);
const char domain_name[] = "hye.su";
uint8_t addr[4]; uint8_t addr[4];
{ int8_t res;
char domain_name[] = "hye.su"; uint8_t retries = 0;
while (retries < 10) {
Delay_Ms(250);
printf("Resolving domain name \"%s\"...\r\n", domain_name); printf("Resolving domain name \"%s\"...\r\n", domain_name);
int8_t res = DNS_run(dns, (uint8_t*)&domain_name, addr); res = DNS_run(dns, (uint8_t *)domain_name, addr);
if (res != 1) {
printf("DNS_run() failed, res = %d", res); if (res == 1) {
return 1;
}
printf("Result: %d.%d.%d.%d\r\n", addr[0], addr[1], addr[2], addr[3]); printf("Result: %d.%d.%d.%d\r\n", addr[0], addr[1], addr[2], addr[3]);
} else {
printf("DNS_run() failed, res = %d. Retries: %u\r\n", res, retries);
} }
while (1) { retries++;
GPIOB->BSHR = (1 << 3) | (1 << 4);
printf("+%lu\n", count++);
Delay_Ms(1000); // from ch32v003fun.h
GPIOB->BCR = (1 << 3) | (1 << 4);
printf("-%lu\n", count++);
Delay_Ms(1000);
} }
} }