huh
This commit is contained in:
41
README.md
41
README.md
@@ -6,10 +6,10 @@ W5500 VERSIONR: 0x04
|
||||
Registering DHCP callbacks...
|
||||
Calling DHCP_run()...
|
||||
> Send DHCP_DISCOVER
|
||||
DHCP message : 192.168.102.1(67) 311 received.
|
||||
DHCP message : 192.168.102.1(67) 311 received.
|
||||
> Receive DHCP_OFFER
|
||||
> Send DHCP_REQUEST
|
||||
DHCP message : 192.168.102.1(67) 311 received.
|
||||
DHCP message : 192.168.102.1(67) 311 received.
|
||||
> Receive DHCP_ACK
|
||||
|
||||
> Check leased IP - OK
|
||||
@@ -23,20 +23,49 @@ Calling DNS_init()...
|
||||
Resolving domain name "hye.su"...
|
||||
> DNS Query to DNS Server : 192.168.102.1
|
||||
> Receive DNS message from 192.168.102.1(53). len = 21
|
||||
> 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
|
||||
```
|
||||
|
||||
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`
|
||||
**DNS_run() failed, res = 0**
|
||||
> **DNS_run() failed, res = 0**
|
||||
|
||||
w/ WCH HAL (none-os).. I get a full response
|
||||
|
||||
> 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 `
|
||||
Result: 172.67.180.154
|
||||
> Result: 172.67.180.154
|
||||
|
||||
`RCC_CTLR`, GPIO Registers, `SPIx_CTLR1` registers are identical
|
||||
|
||||
## LA
|
||||
|
||||
### ch32v003fun
|
||||
|
||||

|
||||
|
||||
```
|
||||
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
|
||||
|
||||

|
||||
|
||||
```
|
||||
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
|
||||
// Initialize GPIO for W5500 CS
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||
@@ -80,4 +109,4 @@ Result: 172.67.180.154
|
||||
|
||||
SPI_Cmd(SPI1, ENABLE);
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
BIN
notes/2024-10-10-191033_1876x540_scrot.png
Normal file
BIN
notes/2024-10-10-191033_1876x540_scrot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 126 KiB |
BIN
notes/2024-10-10-191043_1891x525_scrot.png
Normal file
BIN
notes/2024-10-10-191043_1891x525_scrot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 120 KiB |
34
src/main.c
34
src/main.c
@@ -74,8 +74,8 @@ void init_spi(void) {
|
||||
SPI1->CTLR1 = 0;
|
||||
|
||||
// set prescaler
|
||||
// 001: FPCLK/4;
|
||||
SPI1->CTLR1 = (SPI1->CTLR1 & ~SPI_CTLR1_BR) | (0x1 << 3);
|
||||
// 011: FPCLK/16
|
||||
SPI1->CTLR1 = (SPI1->CTLR1 & ~SPI_CTLR1_BR) | (0x3 << 3);
|
||||
|
||||
// set clock polarity and phase
|
||||
SPI1->CTLR1 |= (SPI_CPOL_Low | SPI_CPHA_1Edge);
|
||||
@@ -174,25 +174,23 @@ int main(void) {
|
||||
printf("Calling DNS_init()...\r\n");
|
||||
DNS_init(DNS_SOCKET, dns_buffer);
|
||||
|
||||
const char domain_name[] = "hye.su";
|
||||
uint8_t addr[4];
|
||||
{
|
||||
char domain_name[] = "hye.su";
|
||||
int8_t res;
|
||||
uint8_t retries = 0;
|
||||
|
||||
while (retries < 10) {
|
||||
Delay_Ms(250);
|
||||
|
||||
printf("Resolving domain name \"%s\"...\r\n", domain_name);
|
||||
int8_t res = DNS_run(dns, (uint8_t*)&domain_name, addr);
|
||||
if (res != 1) {
|
||||
printf("DNS_run() failed, res = %d", res);
|
||||
return 1;
|
||||
res = DNS_run(dns, (uint8_t *)domain_name, addr);
|
||||
|
||||
if (res == 1) {
|
||||
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);
|
||||
}
|
||||
printf("Result: %d.%d.%d.%d\r\n", addr[0], addr[1], addr[2], addr[3]);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
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);
|
||||
retries++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user