Skip to content

Commit 4beff40

Browse files
cores/psoc6: ./libraries: Format source code using clang.
Signed-off-by: Ramya Subramanyam <[email protected]>
1 parent a18f77d commit 4beff40

File tree

10 files changed

+56
-54
lines changed

10 files changed

+56
-54
lines changed

cores/psoc6/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
#include "time.h"
2929

30-
#define ARDUINO_MAIN_TASK_STACK_SIZE (4096u)
31-
#define ARDUINO_MAIN_TASK_PRIORITY (2u)
30+
#define ARDUINO_MAIN_TASK_STACK_SIZE (4096u)
31+
#define ARDUINO_MAIN_TASK_PRIORITY (2u)
3232

3333
TaskHandle_t arduino_main_task_handle;
3434

@@ -54,7 +54,8 @@ int main() {
5454

5555
time_init();
5656

57-
xTaskCreate(arduino_main_task, "arduino-main-task", ARDUINO_MAIN_TASK_STACK_SIZE, NULL, ARDUINO_MAIN_TASK_PRIORITY, &arduino_main_task_handle);
57+
xTaskCreate(arduino_main_task, "arduino-main-task", ARDUINO_MAIN_TASK_STACK_SIZE, NULL,
58+
ARDUINO_MAIN_TASK_PRIORITY, &arduino_main_task_handle);
5859
vTaskStartScheduler();
5960

6061
/* Should never get here */

libraries/WiFi/src/SecSocket.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Socket::Socket():
1616
remote_ip(0, 0, 0, 0),
1717
_port(0) {
1818

19+
Socket::Socket()
20+
: socket(nullptr),
21+
_status(SOCKET_STATUS_UNINITED),
22+
_last_error(CY_RSLT_SUCCESS),
23+
remote_ip(0, 0, 0, 0),
24+
_port(0) {
1925
}
2026

2127
void Socket::begin() {
@@ -113,7 +119,7 @@ void Socket::listen(int max_connections) {
113119
_status = SOCKET_STATUS_LISTENING;
114120
}
115121

116-
bool Socket::accept(Socket & client_socket) {
122+
bool Socket::accept(Socket &client_socket) {
117123
cy_socket_sockaddr_t peer_addr;
118124
uint32_t peer_addr_len;
119125

libraries/WiFi/src/SecSocket.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef CY_SECURE_SOCKET_H
22
#define CY_SECURE_SOCKET_H
33

4-
#include "cy_secure_sockets.h"
54
#include "IPAddress.h"
65
#include "RingBuffer.h"
6+
#include "cy_secure_sockets.h"
77

88
typedef enum {
99
SOCKET_STATUS_UNINITED = 0,
@@ -19,7 +19,6 @@ typedef enum {
1919
class Socket {
2020

2121
public:
22-
2322
Socket();
2423

2524
void begin();
@@ -35,7 +34,7 @@ class Socket {
3534
bool connect(const char *host, uint16_t port);
3635

3736
void listen(int max_connections);
38-
bool accept(Socket & client_socket);
37+
bool accept(Socket &client_socket);
3938
uint32_t send(const void *data, uint32_t len);
4039
uint32_t available();
4140
int peek();
@@ -51,7 +50,6 @@ class Socket {
5150
cy_rslt_t getLastError();
5251

5352
private:
54-
5553
cy_socket_t socket;
5654
socket_status_t _status;
5755
cy_rslt_t _last_error;
@@ -62,7 +60,7 @@ class Socket {
6260
void setOptCallback(int optname, cy_socket_callback_t cback, void *arg);
6361

6462
static const uint16_t RX_BUFFER_SIZE = 256;
65-
arduino::RingBufferN < RX_BUFFER_SIZE > rx_buf;
63+
arduino::RingBufferN<RX_BUFFER_SIZE> rx_buf;
6664

6765
bool connect(cy_socket_sockaddr_t *addr);
6866
void receiveCallback();

libraries/WiFi/src/WiFi.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,9 @@ wifi_error_t WiFiClass::getLastError() {
157157

158158

159159
WiFiClass::WiFiClass() {
160-
161160
}
162161

163162
WiFiClass::~WiFiClass() {
164-
165163
}
166164

167165
wifi_error_t WiFiClass::wcm_init(cy_wcm_interface_t mode) {

libraries/WiFi/src/WiFi.h

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
#include "WiFiServer.h"
99

1010
#include "cy_wcm.h"
11+
#include <stdint.h>
1112

1213
/**
1314
* TODO:
1415
* - Adapt the enum list conveniently. Do we need to keep all?
1516
* - Move it to some header file?
16-
*/
17+
*/
1718
typedef enum {
1819
WL_NO_SHIELD = 255,
1920
WL_NO_MODULE = 255,
@@ -53,23 +54,22 @@ typedef enum {
5354
class WiFiClass {
5455

5556
public:
56-
5757
/* Return the WiFi class singleton */
58-
static WiFiClass & get_instance();
58+
static WiFiClass &get_instance();
5959

6060
/* Start Wifi connection for OPEN networks
61-
*
62-
* param ssid: Pointer to the SSID string.
63-
*/
61+
*
62+
* param ssid: Pointer to the SSID string.
63+
*/
6464
int begin(const char *ssid);
6565

6666
/* Start WiFi connection with passphrase
67-
* the most secure supported mode will be automatically selected
68-
*
69-
* param ssid: Pointer to the SSID string.
70-
* param passphrase: Passphrase. Valid characters in a passphrase
71-
* must be between ASCII 32-126 (decimal).
72-
*/
67+
* the most secure supported mode will be automatically selected
68+
*
69+
* param ssid: Pointer to the SSID string.
70+
* param passphrase: Passphrase. Valid characters in a passphrase
71+
* must be between ASCII 32-126 (decimal).
72+
*/
7373
int begin(const char *ssid, const char *passphrase);
7474

7575
/* WEP is not supported by WCM class as considered an insecure encryption. */
@@ -101,11 +101,11 @@ class WiFiClass {
101101
uint8_t beginAP(const char *ssid, const char *passphrase, uint8_t channel);
102102

103103
/*
104-
* Get the interface IP address.
105-
* Currently only IPv4 is supported.
106-
*
107-
* return: IP address value. Returns 0.0.0.0 in case of error.
108-
*/
104+
* Get the interface IP address.
105+
* Currently only IPv4 is supported.
106+
*
107+
* return: IP address value. Returns 0.0.0.0 in case of error.
108+
*/
109109
IPAddress localIP();
110110

111111
/*
@@ -124,9 +124,10 @@ class WiFiClass {
124124
* WL_AP_LISTENING : assigned when the listening for connections in Access Point mode;
125125
* WL_NO_SHIELD: assigned when no WiFi shield is present;
126126
* WL_NO_MODULE: assigned when the communication with an integrated WiFi module fails;
127-
* WL_IDLE_STATUS: it is a temporary status assigned when WiFi.begin() is called and remains active until the number of attempts expires (resulting in WL_CONNECT_FAILED) or a connection is established (resulting in WL_CONNECTED);
128-
* WL_NO_SSID_AVAIL: assigned when no SSID are available;
129-
* WL_SCAN_COMPLETED: assigned when the scan networks is completed;
127+
* WL_IDLE_STATUS: it is a temporary status assigned when WiFi.begin() is called and remains
128+
* active until the number of attempts expires (resulting in WL_CONNECT_FAILED) or a connection
129+
* is established (resulting in WL_CONNECTED); WL_NO_SSID_AVAIL: assigned when no SSID are
130+
* available; WL_SCAN_COMPLETED: assigned when the scan networks is completed;
130131
* WL_CONNECT_FAILED: assigned when the connection fails for all the attempts;
131132
* WL_CONNECTION_LOST: assigned when the connection is lost;
132133
* WL_DISCONNECTED: assigned when disconnected from a network;
@@ -138,23 +139,21 @@ class WiFiClass {
138139
wifi_error_t getLastError();
139140

140141
private:
141-
142142
/* Extension of cy_wcm_interface_t enums. */
143143
#define CY_WCM_INTERFACE_TYPE_UNKNOWN (cy_wcm_interface_t)0xFF
144144

145145
cy_wcm_interface_t _mode = CY_WCM_INTERFACE_TYPE_UNKNOWN;
146146
volatile wifi_status_t _status = WIFI_STATUS_UNINITED;
147147
wifi_error_t _last_error = WIFI_ERROR_NONE;
148148

149-
150149
/* The WiFi class is implemented as singleton.
151150
The constructor and destructor are private. */
152151
WiFiClass();
153152
~WiFiClass();
154153

155154
/* Delete copy constructor and assignment operator */
156-
WiFiClass(const WiFiClass&) = delete;
157-
WiFiClass& operator = (const WiFiClass&) = delete;
155+
WiFiClass(const WiFiClass &) = delete;
156+
WiFiClass &operator=(const WiFiClass &) = delete;
158157

159158
/**
160159
* Initialize the WiFi connection manager.

libraries/WiFi/src/WiFiClient.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@ WiFiClient::operator bool() {
9797
IPAddress WiFiClient::remoteIP() {
9898
return socket->remoteIP();
9999
}
100+
100101
uint16_t WiFiClient::remotePort() {
101102
return socket->port();
102103
};
103104

104-
WiFiClient::WiFiClient(const WiFiClient& other) : socket(other.socket) {
105+
WiFiClient::WiFiClient(const WiFiClient &other)
106+
: socket(other.socket) {
105107
}
106108

107109
WiFiClient& WiFiClient::operator = (const WiFiClient& other) {

libraries/WiFi/src/WiFiClient.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
#include <SecSocket.h>
77
#include "Client.h"
88
#include "Print.h"
9+
#include <Socket.h>
10+
#include <memory>
911

1012
class WiFiClient: public arduino::Client {
1113

1214
public:
13-
1415
WiFiClient();
1516

1617
int connect(IPAddress ip, uint16_t port);
@@ -33,20 +34,18 @@ class WiFiClient: public arduino::Client {
3334
using Print::print;
3435
using Print::println;
3536

36-
WiFiClient(const WiFiClient& other);
37-
WiFiClient& operator = (const WiFiClient& other);
38-
37+
WiFiClient(const WiFiClient &other);
38+
WiFiClient &operator=(const WiFiClient &other);
3939

4040
private:
41-
4241
/**
4342
* Implemented as shared ptr as this class is used
4443
* in the WiFiServer to keep the WiFiClient objects
4544
* as a list of connected clients.
4645
* Keeping objects will lead to copies which won´t
4746
* update the socket rx_buffer upon interrupts.
48-
*/
49-
std::shared_ptr < Socket > socket;
47+
*/
48+
std::shared_ptr<Socket> socket;
5049

5150
static cy_rslt_t receiveCallback(cy_socket_t socket_handle, void *arg);
5251
static cy_rslt_t disconnectionCallback(cy_socket_t socket_handle, void *arg);

libraries/WiFi/src/WiFiServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ size_t WiFiServer::write(uint8_t data) {
5858
size_t WiFiServer::write(const uint8_t *buf, size_t size) {
5959
size_t written_bytes = 4294967295; /* Maximum value of uint32_t */
6060

61-
for (WiFiClient & client: connected_clients) {
61+
for (WiFiClient &client : connected_clients) {
6262
uint16_t written_bytes_i = client.write(buf, size);
6363
/**
6464
* Keep as written_bytes the smallest value of written bytes to any clients.
@@ -114,7 +114,7 @@ cy_rslt_t WiFiServer::connectionCallback(cy_socket_t socket_handle, void *arg) {
114114
* and use the reference to accept the connection.
115115
*/
116116
server->connected_clients.emplace_back();
117-
WiFiClient & new_client = server->connected_clients.back();
117+
WiFiClient &new_client = server->connected_clients.back();
118118

119119
if (!server->socket.accept(*(new_client.socket))) {
120120
server->connected_clients.pop_back();

libraries/WiFi/src/WiFiServer.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
#ifndef WIFI_SERVER_H
22
#define WIFI_SERVER_H
33

4+
#include "Server.h"
5+
#include <Socket.h>
6+
#include <WiFiClient.h>
47
#include <stdint.h>
58
#include <vector>
69
#include <WiFiClient.h>
710
#include <SecSocket.h>
811
#include "Server.h"
912

10-
class WiFiServer: public arduino::Server {
13+
class WiFiServer : public arduino::Server {
1114

1215
public:
13-
1416
WiFiServer();
1517

1618
void begin(uint16_t port);
1719
void begin();
1820

19-
WiFiClient & available();
21+
WiFiClient &available();
2022
size_t write(uint8_t) override;
2123
size_t write(const uint8_t *buf, size_t size) override;
2224

@@ -31,12 +33,11 @@ class WiFiServer: public arduino::Server {
3133
uint8_t connectedSize();
3234

3335
private:
34-
3536
Socket socket;
3637

3738
static const uint16_t SERVER_RECV_TIMEOUT_MS = 500;
3839
static const uint32_t SERVER_MAX_CLIENTS = 32;
39-
std::vector < WiFiClient > connected_clients;
40+
std::vector<WiFiClient> connected_clients;
4041

4142
static cy_rslt_t connectionCallback(cy_socket_t socket_handle, void *arg);
4243
static cy_rslt_t receiveCallback(cy_socket_t socket_handle, void *arg);

libraries/Wire/Wire.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#ifndef WIRE_H
22
#define WIRE_H
33

4-
#include <Arduino.h>
54
#include "cyhal_i2c.h"
5+
#include <Arduino.h>
66

77
class TwoWire {
88
public:
9-
109
static const size_t BUFFER_LENGTH = 32;
1110
static const uint32_t I2C_DEFAULT_FREQ = 100000;
1211

@@ -38,7 +37,7 @@ class TwoWire {
3837
void onRequest(void (*function)(void));
3938

4039
private:
41-
static TwoWire * instances[I2C_HOWMANY];
40+
static TwoWire *instances[I2C_HOWMANY];
4241
void _begin();
4342
cyhal_gpio_t sda_pin;
4443
cyhal_gpio_t scl_pin;
@@ -63,7 +62,6 @@ class TwoWire {
6362
void onReceiveService(int);
6463
static void i2c_event_handler(void *callback_arg, cyhal_i2c_event_t event);
6564
void i2c_event_handler_member(cyhal_i2c_event_t event);
66-
6765
};
6866

6967
#if (I2C_HOWMANY > 0)

0 commit comments

Comments
 (0)