From 238c5c96558cabddea74f800b4ab90fb127bc1ab Mon Sep 17 00:00:00 2001 From: ccbruce0812 Date: Mon, 6 Mar 2017 10:11:23 +0800 Subject: [PATCH 01/12] Added submodules. --- .gitmodules | 9 +++++++++ examples/rda5807m_test | 1 + extras/kt0803l | 1 + extras/rda5807m | 1 + 4 files changed, 12 insertions(+) create mode 160000 examples/rda5807m_test create mode 160000 extras/kt0803l create mode 160000 extras/rda5807m diff --git a/.gitmodules b/.gitmodules index 19b3794..3f62356 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,3 +28,12 @@ [submodule "extras/crc_generic/crc_lib"] path = extras/crc_generic/crc_lib url = https://github.com/Zaltora/crc_generic_lib.git +[submodule "extras/kt0803l"] + path = extras/kt0803l + url = https://github.com/ccbruce0812/kt0803l.git +[submodule "extras/rda5807m"] + path = extras/rda5807m + url = https://github.com/ccbruce0812/rda5807m.git +[submodule "examples/rda5807m_test"] + path = examples/rda5807m_test + url = https://github.com/ccbruce0812/rda5807m_test.git diff --git a/examples/rda5807m_test b/examples/rda5807m_test new file mode 160000 index 0000000..439b9fa --- /dev/null +++ b/examples/rda5807m_test @@ -0,0 +1 @@ +Subproject commit 439b9fa3dfd8ea29cfef60184889ea461f56a7d7 diff --git a/extras/kt0803l b/extras/kt0803l new file mode 160000 index 0000000..32f7a13 --- /dev/null +++ b/extras/kt0803l @@ -0,0 +1 @@ +Subproject commit 32f7a131390d2f73f5260fa383383f1fae0e96db diff --git a/extras/rda5807m b/extras/rda5807m new file mode 160000 index 0000000..11b88af --- /dev/null +++ b/extras/rda5807m @@ -0,0 +1 @@ +Subproject commit 11b88afb49bc484e96e7f9f2fa138dd27df364f4 From 189a0450a6b430b2d6205848192e4b1ed28d75a4 Mon Sep 17 00:00:00 2001 From: ccbruce0812 Date: Mon, 6 Mar 2017 10:31:18 +0800 Subject: [PATCH 02/12] Updated rda5807m. --- extras/rda5807m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/rda5807m b/extras/rda5807m index 11b88af..da5e0f0 160000 --- a/extras/rda5807m +++ b/extras/rda5807m @@ -1 +1 @@ -Subproject commit 11b88afb49bc484e96e7f9f2fa138dd27df364f4 +Subproject commit da5e0f0922031af53ef040943b1aac09ae75ebe7 From 2ac5a5d89ca083021d99357d7282f62ed6323fbe Mon Sep 17 00:00:00 2001 From: ccbruce0812 Date: Fri, 17 Mar 2017 16:17:55 +0800 Subject: [PATCH 03/12] Updated rda5807 extra. --- extras/rda5807m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/rda5807m b/extras/rda5807m index da5e0f0..fc137d4 160000 --- a/extras/rda5807m +++ b/extras/rda5807m @@ -1 +1 @@ -Subproject commit da5e0f0922031af53ef040943b1aac09ae75ebe7 +Subproject commit fc137d42d5189a8d830f027fcd3c65c3048aa9ab From 446cf5987a6d51d8e4adf077fb31941da29ea8f0 Mon Sep 17 00:00:00 2001 From: brucehsu Date: Fri, 19 May 2017 16:20:28 +0800 Subject: [PATCH 04/12] 1. Added new submodule mcpwm. --- .gitmodules | 3 +++ extras/mcpwm | 1 + 2 files changed, 4 insertions(+) create mode 160000 extras/mcpwm diff --git a/.gitmodules b/.gitmodules index 3f62356..8fa55e5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,3 +37,6 @@ [submodule "examples/rda5807m_test"] path = examples/rda5807m_test url = https://github.com/ccbruce0812/rda5807m_test.git +[submodule "extras/mcpwm"] + path = extras/mcpwm + url = https://github.com/ccbruce0812/mcpwm.git diff --git a/extras/mcpwm b/extras/mcpwm new file mode 160000 index 0000000..d72f86f --- /dev/null +++ b/extras/mcpwm @@ -0,0 +1 @@ +Subproject commit d72f86fba9a63c8e1a0b3bcd783fe11e04e77f70 From 20342ee1e7575480f64a522c7fb00a4c486d05aa Mon Sep 17 00:00:00 2001 From: BruceHsu Date: Wed, 24 May 2017 00:08:18 +0800 Subject: [PATCH 05/12] Updated mcpwm. --- extras/mcpwm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/mcpwm b/extras/mcpwm index d72f86f..bf28254 160000 --- a/extras/mcpwm +++ b/extras/mcpwm @@ -1 +1 @@ -Subproject commit d72f86fba9a63c8e1a0b3bcd783fe11e04e77f70 +Subproject commit bf282543d9827bfef7e5bb3d99f5a087b54b9c97 From 4c0ae1145852cec54a10541c06292a1c00fd062e Mon Sep 17 00:00:00 2001 From: brucehsu Date: Thu, 25 May 2017 14:11:39 +0800 Subject: [PATCH 06/12] Updated mcpwm. --- extras/mcpwm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/mcpwm b/extras/mcpwm index bf28254..31843b0 160000 --- a/extras/mcpwm +++ b/extras/mcpwm @@ -1 +1 @@ -Subproject commit bf282543d9827bfef7e5bb3d99f5a087b54b9c97 +Subproject commit 31843b00b4562ac63f00f07330d54280bbac505b From eab2420e431b9af2dff73be3bdd47c03d0d00024 Mon Sep 17 00:00:00 2001 From: BruceHsu Date: Mon, 29 May 2017 10:34:08 +0800 Subject: [PATCH 07/12] Updated mcpwm. --- extras/mcpwm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/mcpwm b/extras/mcpwm index bf28254..626f547 160000 --- a/extras/mcpwm +++ b/extras/mcpwm @@ -1 +1 @@ -Subproject commit bf282543d9827bfef7e5bb3d99f5a087b54b9c97 +Subproject commit 626f547cd748dc8bab1d29ee9d06c5cb8d5ae421 From b6509629ada8a88b1ed04e37fc4dbd83fd1f440c Mon Sep 17 00:00:00 2001 From: brucehsu Date: Tue, 3 Oct 2017 11:05:23 +0800 Subject: [PATCH 08/12] 1. Updated mcpwm & lwip. 2. Fixed the problem of duplicated LWIP_RAND. --- extras/mcpwm | 2 +- lwip/include/arch/cc.h | 2 ++ lwip/lwip | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/extras/mcpwm b/extras/mcpwm index 626f547..0f76d81 160000 --- a/extras/mcpwm +++ b/extras/mcpwm @@ -1 +1 @@ -Subproject commit 626f547cd748dc8bab1d29ee9d06c5cb8d5ae421 +Subproject commit 0f76d8141318899388c990c45c347ae5f37b9c07 diff --git a/lwip/include/arch/cc.h b/lwip/include/arch/cc.h index e7cf291..74fc332 100644 --- a/lwip/include/arch/cc.h +++ b/lwip/include/arch/cc.h @@ -101,6 +101,8 @@ typedef int sys_prot_t; #define LWIP_PLATFORM_HTONS(_n) ((u16_t)((((_n) & 0xff) << 8) | (((_n) >> 8) & 0xff))) #define LWIP_PLATFORM_HTONL(_n) ((u32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) )) +#ifndef LWIP_RAND #define LWIP_RAND() hwrand() +#endif #endif /* __ARCH_CC_H__ */ diff --git a/lwip/lwip b/lwip/lwip index 74676d4..e5bf00e 160000 --- a/lwip/lwip +++ b/lwip/lwip @@ -1 +1 @@ -Subproject commit 74676d46f0bc5ed82515f8e247008b7c45ec6cf6 +Subproject commit e5bf00eab33ad371994368dbe53f7b2d456ec884 From e9135866f225e7bf9ae5b8f3f378f97a035cdcd4 Mon Sep 17 00:00:00 2001 From: brucehsu Date: Tue, 3 Oct 2017 19:02:37 +0800 Subject: [PATCH 09/12] Able to fetch leases from dhcpserver. --- extras/dhcpserver/dhcpserver.c | 29 ++++++++++++++++++++++++++ extras/dhcpserver/include/dhcpserver.h | 7 ++++++- 2 files changed, 35 insertions(+), 1 deletion(-) mode change 100644 => 100755 extras/dhcpserver/dhcpserver.c mode change 100644 => 100755 extras/dhcpserver/include/dhcpserver.h diff --git a/extras/dhcpserver/dhcpserver.c b/extras/dhcpserver/dhcpserver.c old mode 100644 new mode 100755 index 934beb2..9df4b75 --- a/extras/dhcpserver/dhcpserver.c +++ b/extras/dhcpserver/dhcpserver.c @@ -106,6 +106,29 @@ void dhcpserver_start(const ip4_addr_t *first_client_addr, uint8_t max_leases) xTaskCreate(dhcpserver_task, "DHCP Server", 448, NULL, 2, &dhcpserver_task_handle); } +int dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity) { + int i=0, count=0; + + taskENTER_CRITICAL(); + + for(i=0;imax_leases;i++) { + if(count>=capacity) { + count=capacity; + break; + } + + if(state->leases[i].active) { + leases[count].hwaddr=state->leases[i].hwaddr; + leases[count].ipaddr=*state->first_client_addr; + leases[count].ipaddr.addr+=count; + count++; + } + } + + taskLEAVE_CRITICAL(); + return count; +} + void dhcpserver_stop(void) { if (dhcpserver_task_handle) { @@ -150,6 +173,8 @@ static void dhcpserver_task(void *pxParameter) printf("DHCP Server Error: Failed to receive DHCP packet. err=%d\r\n", err); continue; } + + taskENTER_CRITICAL(); /* expire any leases that have passed */ uint32_t now = xTaskGetTickCount(); @@ -169,6 +194,7 @@ static void dhcpserver_task(void *pxParameter) if (netbuf_len(netbuf) < offsetof(struct dhcp_msg, options)) { /* too short to be a valid DHCP client message */ netbuf_delete(netbuf); + taskLEAVE_CRITICAL(); continue; } if (netbuf_len(netbuf) >= sizeof(struct dhcp_msg)) { @@ -182,6 +208,7 @@ static void dhcpserver_task(void *pxParameter) DHCP_OPTION_MESSAGE_TYPE_LEN, NULL); if (!message_type) { printf("DHCP Server Error: No message type field found"); + taskLEAVE_CRITICAL(); continue; } @@ -207,6 +234,8 @@ static void dhcpserver_task(void *pxParameter) printf("DHCP Server Error: Unsupported message type %d\r\n", *message_type); break; } + + taskLEAVE_CRITICAL(); } } diff --git a/extras/dhcpserver/include/dhcpserver.h b/extras/dhcpserver/include/dhcpserver.h old mode 100644 new mode 100755 index 62fa0ac..4fff9e7 --- a/extras/dhcpserver/include/dhcpserver.h +++ b/extras/dhcpserver/include/dhcpserver.h @@ -18,6 +18,11 @@ extern "C" { #endif +typedef struct { + uint8_t hwaddr[NETIF_MAX_HWADDR_LEN]; + ip4_addr_t ipaddr; +} dhcpserver_lease_t; + /* Start DHCP server. Static IP of server should already be set and network interface enabled. @@ -28,7 +33,7 @@ extern "C" { */ void dhcpserver_start(const ip4_addr_t *first_client_addr, uint8_t max_leases); -void dhcpserver_get_lease(const ip4_addr_t *first_client_addr, uint8_t max_leases); +int dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity); /* Stop DHCP server. */ From cbdacf5ca1fdca02da042cd25a4cc7521966e012 Mon Sep 17 00:00:00 2001 From: BruceHsu Date: Tue, 3 Oct 2017 23:04:37 +0800 Subject: [PATCH 10/12] Updated .gitmodule. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 52db9b8..d0d6642 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "lwip/lwip"] path = lwip/lwip - url = https://github.com/ourairquality/lwip.git + url = https://github.com/ccbruce0812/lwip.git [submodule "extras/mbedtls/mbedtls"] path = extras/mbedtls/mbedtls url = https://github.com/ARMmbed/mbedtls.git From c1124f9f7cce552966d525707500e5b5d5b9a627 Mon Sep 17 00:00:00 2001 From: BruceHsu Date: Wed, 4 Oct 2017 22:18:21 +0800 Subject: [PATCH 11/12] Refine dhcpserver_get_leases(). Add LWIP_RAW support. --- extras/dhcpserver/dhcpserver.c | 12 ++++++------ extras/dhcpserver/include/dhcpserver.h | 2 +- lwip/include/lwipopts.h | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) mode change 100644 => 100755 lwip/include/lwipopts.h diff --git a/extras/dhcpserver/dhcpserver.c b/extras/dhcpserver/dhcpserver.c index 9df4b75..87a9c6d 100755 --- a/extras/dhcpserver/dhcpserver.c +++ b/extras/dhcpserver/dhcpserver.c @@ -118,14 +118,14 @@ int dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity) { } if(state->leases[i].active) { - leases[count].hwaddr=state->leases[i].hwaddr; - leases[count].ipaddr=*state->first_client_addr; + memcpy(&leases[count].hwaddr, &state->leases[i].hwaddr, sizeof(uint8_t)*6); + ip4_addr_copy(leases[count].ipaddr, state->first_client_addr); leases[count].ipaddr.addr+=count; count++; } } - taskLEAVE_CRITICAL(); + taskEXIT_CRITICAL(); return count; } @@ -194,7 +194,7 @@ static void dhcpserver_task(void *pxParameter) if (netbuf_len(netbuf) < offsetof(struct dhcp_msg, options)) { /* too short to be a valid DHCP client message */ netbuf_delete(netbuf); - taskLEAVE_CRITICAL(); + taskEXIT_CRITICAL(); continue; } if (netbuf_len(netbuf) >= sizeof(struct dhcp_msg)) { @@ -208,7 +208,7 @@ static void dhcpserver_task(void *pxParameter) DHCP_OPTION_MESSAGE_TYPE_LEN, NULL); if (!message_type) { printf("DHCP Server Error: No message type field found"); - taskLEAVE_CRITICAL(); + taskEXIT_CRITICAL(); continue; } @@ -235,7 +235,7 @@ static void dhcpserver_task(void *pxParameter) break; } - taskLEAVE_CRITICAL(); + taskEXIT_CRITICAL(); } } diff --git a/extras/dhcpserver/include/dhcpserver.h b/extras/dhcpserver/include/dhcpserver.h index 4fff9e7..f6a3a25 100755 --- a/extras/dhcpserver/include/dhcpserver.h +++ b/extras/dhcpserver/include/dhcpserver.h @@ -19,7 +19,7 @@ extern "C" { #endif typedef struct { - uint8_t hwaddr[NETIF_MAX_HWADDR_LEN]; + uint8_t hwaddr[6]; ip4_addr_t ipaddr; } dhcpserver_lease_t; diff --git a/lwip/include/lwipopts.h b/lwip/include/lwipopts.h old mode 100644 new mode 100755 index 4d69eda..c86dace --- a/lwip/include/lwipopts.h +++ b/lwip/include/lwipopts.h @@ -221,6 +221,9 @@ ---------- RAW options ---------- --------------------------------- */ +#ifndef LWIP_RAW +#define LWIP_RAW 1 +#endif /* ---------------------------------- From 2e4ec5c96e3656cebae651f9395c51c489b232ad Mon Sep 17 00:00:00 2001 From: brucehsu Date: Thu, 5 Oct 2017 09:30:06 +0800 Subject: [PATCH 12/12] Uniformed declaration of dhcpserver_get_leases(). --- extras/dhcpserver/dhcpserver.c | 4 ++-- extras/dhcpserver/include/dhcpserver.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extras/dhcpserver/dhcpserver.c b/extras/dhcpserver/dhcpserver.c index 87a9c6d..e0debff 100755 --- a/extras/dhcpserver/dhcpserver.c +++ b/extras/dhcpserver/dhcpserver.c @@ -106,8 +106,8 @@ void dhcpserver_start(const ip4_addr_t *first_client_addr, uint8_t max_leases) xTaskCreate(dhcpserver_task, "DHCP Server", 448, NULL, 2, &dhcpserver_task_handle); } -int dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity) { - int i=0, count=0; +uint32_t dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity) { + uint32_t i=0, count=0; taskENTER_CRITICAL(); diff --git a/extras/dhcpserver/include/dhcpserver.h b/extras/dhcpserver/include/dhcpserver.h index f6a3a25..814b461 100755 --- a/extras/dhcpserver/include/dhcpserver.h +++ b/extras/dhcpserver/include/dhcpserver.h @@ -33,7 +33,7 @@ typedef struct { */ void dhcpserver_start(const ip4_addr_t *first_client_addr, uint8_t max_leases); -int dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity); +uint32_t dhcpserver_get_leases(dhcpserver_lease_t *leases, uint32_t capacity); /* Stop DHCP server. */