Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wifi #65

Merged
merged 39 commits into from
Feb 27, 2025
Merged

Wifi #65

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7909fe2
mtb-integration: Added wifi connectivity submodules.
jaenrig-ifx Dec 17, 2024
e031d9c
variants/CY8CKIT-062S2-AI: Updated mtb-libs core with connectivity libs.
jaenrig-ifx Dec 17, 2024
e28c127
variants/CY8CKIT-062S2-AI/FreeRTOSConfig.h: Added file to temp location.
jaenrig-ifx Dec 17, 2024
b92a293
variants/CY8CKIT-062S2-AI/mbedtls: Added mbedtls as temp location.
jaenrig-ifx Dec 17, 2024
56da82c
extras/mtb-libs: Added missing wifi connectivity sub modules.
jaenrig-ifx Dec 18, 2024
cb64eb7
variants/CY8CKIT-062S2-AI/mtb-libs.a: New static lib no secure sockets.
jaenrig-ifx Jan 23, 2025
01273e7
libraries/WiFi: Added begin, beginAP, end funcs.
jaenrig-ifx Jan 23, 2025
b4ffa53
cores/psoc/main.cpp: Added freertos based main.
jaenrig-ifx Jan 23, 2025
5fbc807
extras/mtb-integration: Modified mtb-libs.a project.
jaenrig-ifx Jan 23, 2025
5f135df
tests/arduino-core-tests: Updated with wifi begin core tests.
jaenrig-ifx Jan 23, 2025
516e6b2
libraries/WiFi/library.properties: Added lib properties to WiFi lib.
jaenrig-ifx Jan 23, 2025
cee2c94
libraries/WiFi/library.properties: Fixed typos in includes.
jaenrig-ifx Jan 29, 2025
45a5bd6
libraries/WiFi/src/WiFi.cpp: Refined begin() function.
jaenrig-ifx Jan 29, 2025
33b0775
libraries/Wifi/src/WiFi: Added status function.
jaenrig-ifx Jan 27, 2025
a4bfb71
libraries/WiFi/src/WiFi: Added localIP function for station.
jaenrig-ifx Jan 27, 2025
57fd17c
libraries/WiFi/src/WiFi: Limit mode to either sta or ap.
jaenrig-ifx Jan 27, 2025
b190524
test/arduino-core-test: Updated test for wifi status and localIP funcs.
jaenrig-ifx Jan 27, 2025
cd3f38d
cores/psoc/time.c: Implemented delay function base on RTOS TaskDelay.
jaenrig-ifx Jan 30, 2025
7806e1b
variants/CY8CKIT-062S2-AI/mtb-libs.a: Added secure socket to static lib.
jaenrig-ifx Jan 30, 2025
09957aa
libraries/WiFi/src/WiFiClient: Added virtual interface skeleton.
jaenrig-ifx Jan 30, 2025
7631f57
libraries/WiFi/src/WiFiServer: Added begin and end basics.
jaenrig-ifx Jan 30, 2025
670c45f
tests/arduino-core-tests: Added client server initial tests.
jaenrig-ifx Jan 30, 2025
08cef79
extras/mtb-integration: Updated reference to secure soc added mtb-libs.
jaenrig-ifx Jan 30, 2025
7146232
libraries/WiFi/src/Socket: Added socket class as wrapping sec socket.
jaenrig-ifx Feb 3, 2025
d668312
libraries/WiFi/src/WiFiClient: Added connect (ip) function.
jaenrig-ifx Feb 3, 2025
1b54af3
libraries/WiFi/src/WiFiServer: Refactored based on Socket class.
jaenrig-ifx Feb 3, 2025
803574d
tests/arduino: Added server begin - client connect test.
jaenrig-ifx Feb 3, 2025
737a3c0
library/WiFi/src/Socket: Added status and error tracking.
jaenrig-ifx Feb 4, 2025
5d00769
library/WiFi/src/WiFiClient: Added connected() and bool operator.
jaenrig-ifx Feb 4, 2025
eb55a09
library/WiFi/src/WiFiServer: Added available() function.
jaenrig-ifx Feb 4, 2025
063009c
tests/arduino-core-test: Updated WiFiServer and WiFiClient tests.
jaenrig-ifx Feb 4, 2025
a77dce7
libraries/WiFi/src/Socket: Renamed global socket for clarity.
jaenrig-ifx Feb 17, 2025
9a82c85
libraries/WiFi: Added write() read() funcs for server and client.
jaenrig-ifx Feb 18, 2025
eeca0aa
tests/arduino-core-tests: Added read/write client server tests.
jaenrig-ifx Feb 19, 2025
e1b58e0
libraries/WiFi: Completed wifi server and client without secure.
jaenrig-ifx Feb 21, 2025
80c11b8
tests/arduino-core-tests: Updated wifi client server classes tests.
jaenrig-ifx Feb 21, 2025
fbbf943
cores/psoc/time: Micros and millis in term of cyhal_timer.
jaenrig-ifx Feb 25, 2025
a1a1718
tests/arduino-core-tests: Updated time tests.
jaenrig-ifx Feb 25, 2025
fa3352c
cores/psoc/time.c: Added max uint32 value as macro.
jaenrig-ifx Feb 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,48 @@
[submodule "tests/arduino-core-tests"]
path = tests/arduino-core-tests
url = https://github.com/Infineon/arduino-core-tests.git
[submodule "extras/mtb-libs/abstraction-rtos"]
path = extras/mtb-libs/abstraction-rtos
url = https://github.com/Infineon/abstraction-rtos.git
[submodule "extras/mtb-libs/clib-support"]
path = extras/mtb-libs/clib-support
url = https://github.com/Infineon/clib-support.git
[submodule "extras/mtb-libs/connectivity-utilities"]
path = extras/mtb-libs/connectivity-utilities
url = https://github.com/Infineon/connectivity-utilities.git
[submodule "extras/mtb-libs/cy-mbedtls-acceleration"]
path = extras/mtb-libs/cy-mbedtls-acceleration
url = https://github.com/Infineon/cy-mbedtls-acceleration.git
[submodule "extras/mtb-libs/freertos"]
path = extras/mtb-libs/freertos
url = https://github.com/Infineon/freertos.git
[submodule "extras/mtb-libs/wifi-connection-manager"]
path = extras/mtb-libs/wifi-connection-manager
url = https://github.com/Infineon/wifi-connection-manager.git
[submodule "extras/mtb-libs/lwip-freertos-integration"]
path = extras/mtb-libs/lwip-freertos-integration
url = https://github.com/Infineon/lwip-freertos-integration.git
[submodule "extras/mtb-libs/lwip-network-interface-integration"]
path = extras/mtb-libs/lwip-network-interface-integration
url = https://github.com/Infineon/lwip-network-interface-integration.git
[submodule "extras/mtb-libs/lwip"]
path = extras/mtb-libs/lwip
url = https://github.com/lwip-tcpip/lwip.git
[submodule "extras/mtb-libs/mbedtls"]
path = extras/mtb-libs/mbedtls
url = https://github.com/Mbed-TLS/mbedtls.git
[submodule "extras/mtb-libs/secure-sockets"]
path = extras/mtb-libs/secure-sockets
url = https://github.com/Infineon/secure-sockets.git
[submodule "extras/mtb-libs/whd-bsp-integration"]
path = extras/mtb-libs/whd-bsp-integration
url = https://github.com/Infineon/whd-bsp-integration.git
[submodule "extras/mtb-libs/wifi-host-driver"]
path = extras/mtb-libs/wifi-host-driver
url = https://github.com/Infineon/wifi-host-driver.git
[submodule "extras/mtb-libs/wifi-resources"]
path = extras/mtb-libs/wifi-resources
url = https://github.com/Infineon/wifi-resources.git
[submodule "extras/mtb-libs/wpa3-external-supplicant"]
path = extras/mtb-libs/wpa3-external-supplicant
url = https://github.com/Infineon/wpa3-external-supplicant.git
31 changes: 24 additions & 7 deletions cores/psoc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,52 @@

#include "cybsp.h"
#include "cy_retarget_io.h"

#include <FreeRTOS.h>
#include <task.h>

#include "time.h"

#define ARDUINO_MAIN_TASK_STACK_SIZE (4096u)
#define ARDUINO_MAIN_TASK_PRIORITY (2u)

TaskHandle_t arduino_main_task_handle;

void arduino_main_task(void *arg);

// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() {
}


/*
* \brief Main entry point of Arduino application
*/
int main(void) {
cy_rslt_t result;

/* Initialize the device and board peripherals */
result = cybsp_init();
time_init();

/* Board init failed. Stop program execution */
if (result != CY_RSLT_SUCCESS) {
CY_ASSERT(0);
}

time_init();

xTaskCreate(arduino_main_task, "arduino-main-task", ARDUINO_MAIN_TASK_STACK_SIZE, NULL, ARDUINO_MAIN_TASK_PRIORITY, &arduino_main_task_handle);
vTaskStartScheduler();

/* Should never get here */
CY_ASSERT(0);
return 0;
}

void arduino_main_task(void *arg) {

/* Enable global interrupts */
interrupts();
initVariant();

setup();

for (;;)
Expand All @@ -58,6 +77,4 @@ int main(void) {
arduino::serialEventRun();
}
}

return 0;
}
74 changes: 46 additions & 28 deletions cores/psoc/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,59 +17,77 @@
*/

#include "Arduino.h"
#include "cy_systick.h"
#include <FreeRTOS.h>
#include <task.h>
#include "cyhal_timer.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Defines */
#define CLOCK_FREQUENCY 8000000
#define MILLISECONDS_PER_SECOND 1000
#define SYSTICK_RELOAD_VAL (CLOCK_FREQUENCY / MILLISECONDS_PER_SECOND - 1) // For 1 ms tick
#define MICROSECONDS_PER_SECOND 1000000
#define MICROS_TO_MILLISECONDS(us) ((unsigned long)((double)(us) / (double)MILLISECONDS_PER_SECOND));
#define MAX_UINT32_VALUE 4294967295

volatile uint32_t systick_count = 0; // Counter to keep track of milliseconds
cyhal_timer_t timer;

void time_increment_millisecond_counter(void) {
systick_count++;
#define time_assert(ret) if (ret != CY_RSLT_SUCCESS) { \
time_error = ret; \
return; \
}

void time_init() {
/* Initialize the systick, set the 8MHz IMO as clock source */
Cy_SysTick_Init(CY_SYSTICK_CLOCK_SOURCE_CLK_IMO, SYSTICK_RELOAD_VAL);
static cy_rslt_t time_error = CY_RSLT_SUCCESS;
/**
* This function can be used for debugging purposes.
* Include in app as extern cy_rslt_t get_time_error();
*/
cy_rslt_t get_time_error() {
return time_error;
}

/* Set Systick interrupt callback */
Cy_SysTick_SetCallback(0, time_increment_millisecond_counter);

/* Enable Systick and the Systick interrupt */
Cy_SysTick_Enable();
void time_init() {
const cyhal_timer_cfg_t timer_cfg =
{
.compare_value = 0, /* Unused */
.period = MAX_UINT32_VALUE, /* With 1MHz freq ~ 70 min overflow.*/
.direction = CYHAL_TIMER_DIR_UP,
.is_compare = false,
.is_continuous = true,
.value = 0
};

cy_rslt_t ret = cyhal_timer_init(&timer, NC, NULL);
time_assert(ret);

ret = cyhal_timer_configure(&timer, &timer_cfg);
time_assert(ret);

ret = cyhal_timer_set_frequency(&timer, MICROSECONDS_PER_SECOND);
time_assert(ret);

ret = cyhal_timer_start(&timer);
time_assert(ret);
}

unsigned long millis() {
// Return the number of milliseconds since the program started
return systick_count;
return MICROS_TO_MILLISECONDS(cyhal_timer_read(&timer));
}

unsigned long micros() {
uint32_t ticks = Cy_SysTick_GetValue();
// Calculate the number of microseconds since the program started
return (systick_count * MILLISECONDS_PER_SECOND) + ((SYSTICK_RELOAD_VAL - ticks) * MILLISECONDS_PER_SECOND / (SYSTICK_RELOAD_VAL + 1));
return cyhal_timer_read(&timer);
}

void delay(unsigned long ms) {
unsigned long start = millis();
while (millis() - start < ms) {
// Yield to allow other processes to run
yield();
}
const TickType_t xDelay = ms / portTICK_PERIOD_MS;
vTaskDelay(xDelay);
}

void delayMicroseconds(unsigned int us) {
unsigned long start = micros();
while (micros() - start < us) {
// Yield to allow other processes to run
yield();
}
const TickType_t xDelay = us / (portTICK_PERIOD_MS * MILLISECONDS_PER_SECOND);
vTaskDelay(xDelay);
}

#ifdef __cplusplus
Expand Down
2 changes: 0 additions & 2 deletions cores/psoc/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#ifndef TIME_H
#define TIME_H

#include "cyhal_timer.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
1 change: 1 addition & 0 deletions extras/mtb-libs/abstraction-rtos
Submodule abstraction-rtos added at b79877
1 change: 1 addition & 0 deletions extras/mtb-libs/clib-support
Submodule clib-support added at 72a71a
1 change: 1 addition & 0 deletions extras/mtb-libs/connectivity-utilities
Submodule connectivity-utilities added at c667f9
1 change: 1 addition & 0 deletions extras/mtb-libs/cy-mbedtls-acceleration
1 change: 1 addition & 0 deletions extras/mtb-libs/freertos
Submodule freertos added at 5c018c
1 change: 1 addition & 0 deletions extras/mtb-libs/lwip
Submodule lwip added at 159e31
1 change: 1 addition & 0 deletions extras/mtb-libs/lwip-freertos-integration
1 change: 1 addition & 0 deletions extras/mtb-libs/mbedtls
Submodule mbedtls added at 1873d3
1 change: 1 addition & 0 deletions extras/mtb-libs/secure-sockets
Submodule secure-sockets added at 726932
1 change: 1 addition & 0 deletions extras/mtb-libs/whd-bsp-integration
Submodule whd-bsp-integration added at 0a6aa5
1 change: 1 addition & 0 deletions extras/mtb-libs/wifi-connection-manager
1 change: 1 addition & 0 deletions extras/mtb-libs/wifi-host-driver
Submodule wifi-host-driver added at 593a77
1 change: 1 addition & 0 deletions extras/mtb-libs/wifi-resources
Submodule wifi-resources added at 224e57
1 change: 1 addition & 0 deletions extras/mtb-libs/wpa3-external-supplicant
10 changes: 10 additions & 0 deletions libraries/WiFi/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name=WiFi
version=0.0.0
author=Infineon Technologies
maintainer=Infineon Technologies <[email protected]>
sentence=Enables WIFI connectivity for PSOC core boards
paragraph=With this library you can instantiate Servers, Clients and send/receive UDP packets through WiFi. The board can connect either to open or encrypted networks (WEP, WPA). The IP address can be assigned statically or through a DHCP. The library can also manage DNS.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mentioned somewhere below WEP is not supported... Should we adapt the description here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that I need to change!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

category=Communication
url=https://github.com/Infineon/arduino-core-psoc/tree/main/libraries/WiFi
architectures=psoc
includes=WiFi.h
Loading
Loading