From 1e854ec1873e8954c57b78e9b9cc2e0d6fc832fb Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 20 Oct 2023 13:47:20 +0200 Subject: [PATCH 1/8] coap: create typedef for CoAP methods --- sys/include/net/coap.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/sys/include/net/coap.h b/sys/include/net/coap.h index dca1f4bae0..7da367af58 100644 --- a/sys/include/net/coap.h +++ b/sys/include/net/coap.h @@ -163,14 +163,20 @@ extern "C" { * @name CoAP method codes used in header * @{ */ -#define COAP_CLASS_REQ (0) -#define COAP_METHOD_GET (1) -#define COAP_METHOD_POST (2) -#define COAP_METHOD_PUT (3) -#define COAP_METHOD_DELETE (4) -#define COAP_METHOD_FETCH (5) -#define COAP_METHOD_PATCH (6) -#define COAP_METHOD_IPATCH (7) +#define COAP_CLASS_REQ (0) /**< Code Class for Request */ + +/** + * @brief CoAP method codes used in request + */ +typedef enum { + COAP_METHOD_GET = 1, /**< GET request (no paylod) */ + COAP_METHOD_POST = 2, /**< POST request (resource processes payload) */ + COAP_METHOD_PUT = 3, /**< PUT request (update resource with payload) */ + COAP_METHOD_DELETE = 4, /**< DELETE request (no payload, remove resource)*/ + COAP_METHOD_FETCH = 5, /**< FETCH request (RFC 8132) */ + COAP_METHOD_PATCH = 6, /**< PATCH request (RFC 8132) */ + COAP_METHOD_IPATCH = 7, /**< iPATCH request (RFC 8132) */ +} coap_method_t; /** @} */ /** From db3294a48125a54779606a4f8eb6a284839e3894 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 20 Oct 2023 13:51:35 +0200 Subject: [PATCH 2/8] nanocoap_sock: make use of coap_method_t --- sys/include/net/nanocoap_sock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/include/net/nanocoap_sock.h b/sys/include/net/nanocoap_sock.h index aee225d2c4..9917996df8 100644 --- a/sys/include/net/nanocoap_sock.h +++ b/sys/include/net/nanocoap_sock.h @@ -205,7 +205,7 @@ typedef struct { nanocoap_sock_t *sock; /**< socket used for the request */ const char *path; /**< path on the server */ uint32_t blknum; /**< current block number */ - uint8_t method; /**< request method (GET, POST, PUT) */ + coap_method_t method; /**< request method (GET, POST, PUT) */ uint8_t blksize; /**< CoAP blocksize exponent */ } coap_block_request_t; @@ -580,7 +580,7 @@ ssize_t nanocoap_request(coap_pkt_t *pkt, const sock_udp_ep_t *local, static inline int nanocoap_block_request_connect_url(coap_block_request_t *ctx, nanocoap_sock_t *sock, const char *url, - uint8_t method, + coap_method_t method, coap_blksize_t blksize) { ctx->sock = sock; From 54362e2c2af195319fd46a750b280908e31b0cff Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 20 Oct 2023 15:14:04 +0200 Subject: [PATCH 3/8] nanocoap/cache: use coap_get_code_raw() --- sys/net/application_layer/gcoap/gcoap.c | 4 ++-- sys/net/application_layer/nanocoap/cache.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/net/application_layer/gcoap/gcoap.c b/sys/net/application_layer/gcoap/gcoap.c index 9afdbd6ef4..6b4641da12 100644 --- a/sys/net/application_layer/gcoap/gcoap.c +++ b/sys/net/application_layer/gcoap/gcoap.c @@ -1180,7 +1180,7 @@ static void _cache_process(gcoap_request_memo_t *memo, #if IS_USED(MODULE_NANOCOAP_CACHE) nanocoap_cache_entry_t *ce; /* cache_key in memo is pre-processor guarded so we need to as well */ - if ((ce = nanocoap_cache_process(memo->cache_key, coap_get_code(&req), pdu, pdu_len))) { + if ((ce = nanocoap_cache_process(memo->cache_key, coap_get_code_raw(&req), pdu, pdu_len))) { ce->truncated = (memo->state == GCOAP_MEMO_RESP_TRUNC); } #else @@ -1288,7 +1288,7 @@ static bool _cache_lookup(gcoap_request_memo_t *memo, _update_memo_cache_key(memo, cache_key); /* cache hit, methods are equal, and cache entry is not stale */ if (*ce && - ((*ce)->request_method == coap_get_code(pdu)) && + ((*ce)->request_method == coap_get_code_raw(pdu)) && !nanocoap_cache_entry_is_stale(*ce, now)) { return true; } diff --git a/sys/net/application_layer/nanocoap/cache.c b/sys/net/application_layer/nanocoap/cache.c index 19140aa48a..1b15577712 100644 --- a/sys/net/application_layer/nanocoap/cache.c +++ b/sys/net/application_layer/nanocoap/cache.c @@ -305,7 +305,7 @@ nanocoap_cache_entry_t *nanocoap_cache_add_by_req(const coap_pkt_t *req, nanocoap_cache_key_generate(req, cache_key); return nanocoap_cache_add_by_key(cache_key, - coap_get_code((coap_pkt_t *)req), + coap_get_code_raw((coap_pkt_t *)req), resp, resp_len); } From a5cc48ad4527073671157f59aae13b50612902f8 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 20 Oct 2023 15:15:08 +0200 Subject: [PATCH 4/8] nanocoap_sock: use coap_get_code_raw() --- sys/net/application_layer/nanocoap/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/application_layer/nanocoap/sock.c b/sys/net/application_layer/nanocoap/sock.c index 05a5a838f9..7a0ee5627b 100644 --- a/sys/net/application_layer/nanocoap/sock.c +++ b/sys/net/application_layer/nanocoap/sock.c @@ -294,7 +294,7 @@ ssize_t nanocoap_sock_request_cb(nanocoap_sock_t *sock, coap_pkt_t *pkt, _send_ack(sock, pkt); /* fall-through */ case COAP_TYPE_ACK: - if (cb && coap_get_code(pkt) == COAP_CODE_EMPTY) { + if (cb && coap_get_code_raw(pkt) == COAP_CODE_EMPTY) { /* empty ACK, wait for separate response */ state = STATE_RESPONSE_RCVD; deadline = _deadline_from_interval(CONFIG_COAP_SEPARATE_RESPONSE_TIMEOUT_MS From a8fc0a25eddb4e05c5f7ee1a686616e1586f1138 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 20 Oct 2023 15:17:07 +0200 Subject: [PATCH 5/8] gcoap_fileserver: use coap_get_code_raw() --- sys/net/application_layer/gcoap/fileserver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/net/application_layer/gcoap/fileserver.c b/sys/net/application_layer/gcoap/fileserver.c index e0add77b51..4af25d3028 100644 --- a/sys/net/application_layer/gcoap/fileserver.c +++ b/sys/net/application_layer/gcoap/fileserver.c @@ -415,7 +415,7 @@ static ssize_t _delete_file(coap_pkt_t *pdu, uint8_t *buf, size_t len, static ssize_t gcoap_fileserver_file_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len, struct requestdata *request) { - switch (coap_get_code(pdu)) { + switch (coap_get_code_raw(pdu)) { case COAP_METHOD_GET: return _get_file(pdu, buf, len, request); #if IS_USED(MODULE_GCOAP_FILESERVER_PUT) @@ -549,7 +549,7 @@ static ssize_t gcoap_fileserver_directory_handler(coap_pkt_t *pdu, uint8_t *buf, struct requestdata *request, const char *root, const char* resource_dir) { - switch (coap_get_code(pdu)) { + switch (coap_get_code_raw(pdu)) { case COAP_METHOD_GET: return _get_directory(pdu, buf, len, request, root, resource_dir); #if IS_USED(MODULE_GCOAP_FILESERVER_PUT) From b88b53b1f3360e44fe0a8e951d08222388f363f3 Mon Sep 17 00:00:00 2001 From: krzysztof-cabaj Date: Tue, 31 Oct 2023 21:04:27 +0100 Subject: [PATCH 6/8] boards/nucleo-l4r5zi:PWM config: Kconfig, Makefile.features, periph_conf.h --- boards/nucleo-l4r5zi/Kconfig | 1 + boards/nucleo-l4r5zi/Makefile.features | 1 + boards/nucleo-l4r5zi/include/periph_conf.h | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/boards/nucleo-l4r5zi/Kconfig b/boards/nucleo-l4r5zi/Kconfig index faeda83cfb..5db0afd3a6 100644 --- a/boards/nucleo-l4r5zi/Kconfig +++ b/boards/nucleo-l4r5zi/Kconfig @@ -18,6 +18,7 @@ config BOARD_NUCLEO_L4R5ZI select HAS_PERIPH_ADC select HAS_PERIPH_I2C select HAS_PERIPH_LPUART + select HAS_PERIPH_PWM select HAS_PERIPH_RTC select HAS_PERIPH_RTT select HAS_PERIPH_SPI diff --git a/boards/nucleo-l4r5zi/Makefile.features b/boards/nucleo-l4r5zi/Makefile.features index dc8f256e03..be171d6a0a 100644 --- a/boards/nucleo-l4r5zi/Makefile.features +++ b/boards/nucleo-l4r5zi/Makefile.features @@ -5,6 +5,7 @@ CPU_MODEL = stm32l4r5zi FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_lpuart +FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_spi diff --git a/boards/nucleo-l4r5zi/include/periph_conf.h b/boards/nucleo-l4r5zi/include/periph_conf.h index 79908c2d81..987aecd0cd 100644 --- a/boards/nucleo-l4r5zi/include/periph_conf.h +++ b/boards/nucleo-l4r5zi/include/periph_conf.h @@ -167,6 +167,11 @@ static const adc_conf_t adc_config[] = { /** @} */ +static const pwm_conf_t pwm_config[] = {{},}; + +#define PWM_NUMOF ARRAY_SIZE(pwm_config) + + #ifdef __cplusplus } #endif From 8899a5996fe37ed55697560681e9df3c48f7b040 Mon Sep 17 00:00:00 2001 From: krzysztof-cabaj Date: Wed, 1 Nov 2023 18:33:44 +0100 Subject: [PATCH 7/8] boards/nucleo-l4r5zi: full PWM config in periph_conf.h --- boards/nucleo-l4r5zi/include/periph_conf.h | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/boards/nucleo-l4r5zi/include/periph_conf.h b/boards/nucleo-l4r5zi/include/periph_conf.h index 987aecd0cd..efb5021070 100644 --- a/boards/nucleo-l4r5zi/include/periph_conf.h +++ b/boards/nucleo-l4r5zi/include/periph_conf.h @@ -167,10 +167,49 @@ static const adc_conf_t adc_config[] = { /** @} */ -static const pwm_conf_t pwm_config[] = {{},}; +/** + * @name PWM configuration + * + * To find appriopate device and channel find in the MCU datasheet table + * concerning "Alternate function AF0 to AF7" a text similar to TIM[X]_CH[Y +], + * where: + * TIM[X] - is device, + * [Y] - describes used channel (indexed from 0), for example TIM2_CH1 is + * channel 0 in configuration structure (cc_chan - field), + * Port column in the table describes connected port. + * + * For Nucleo-L4R5ZI this information is in the datasheet, Table 16, page + * 117. + * + * @{ + */ +static const pwm_conf_t pwm_config[] = { + { + .dev = TIM2, + .rcc_mask = RCC_APB1ENR1_TIM2EN, + .chan = { { .pin = GPIO_PIN(PORT_A, 0) /* CN10 D32 */, .cc_chan = 0}, + { .pin = GPIO_PIN(PORT_A, 1) /* CN10 A8 */, .cc_chan = 1}, + { .pin = GPIO_PIN(PORT_A, 2) /* CN10 D26 */, .cc_chan = 2}, + { .pin = GPIO_PIN(PORT_A, 3) /* CN9 A0 */, .cc_chan = 3} }, + .af = GPIO_AF1, + .bus = APB1 + }, + { + .dev = TIM3, + .rcc_mask = RCC_APB1ENR1_TIM3EN, + .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* CN7 D25 */, .cc_chan = 0}, + { .pin = GPIO_PIN(PORT_E, 4) /* CN9 D57 */, .cc_chan = 1}, + { .pin = GPIO_PIN(PORT_B, 0) /* CN10 D33 */, .cc_chan = 2}, + { .pin = GPIO_PIN(PORT_B, 1) /* CN10 A6 */, .cc_chan = 3} }, + .af = GPIO_AF2, + .bus = APB1 + }, +}; #define PWM_NUMOF ARRAY_SIZE(pwm_config) +/** @} */ #ifdef __cplusplus } From 1b0098cd957fba01616c934da2746e0bde2f0210 Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Thu, 2 Nov 2023 10:16:21 +0100 Subject: [PATCH 8/8] pkg/littlefs2: bump to v2.8.1 --- pkg/littlefs2/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/littlefs2/Makefile b/pkg/littlefs2/Makefile index d74635e0ef..2d7cc7e0f8 100644 --- a/pkg/littlefs2/Makefile +++ b/pkg/littlefs2/Makefile @@ -1,7 +1,7 @@ PKG_NAME=littlefs2 PKG_URL=https://github.com/littlefs-project/littlefs.git -# v2.8 -PKG_VERSION=f77214d1f0a8ccd7ddc7e1204fedd25ee5a41534 +# v2.8.1 +PKG_VERSION=c733d9ec5776dfc949ec6dc71fa9ce3ff71de6e5 PKG_LICENSE=Apache-2.0 include $(RIOTBASE)/pkg/pkg.mk