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..efb5021070 100644 --- a/boards/nucleo-l4r5zi/include/periph_conf.h +++ b/boards/nucleo-l4r5zi/include/periph_conf.h @@ -167,6 +167,50 @@ static const adc_conf_t adc_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 } #endif 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 diff --git a/sys/include/net/coap.h b/sys/include/net/coap.h index b675f653b1..358ebf7a07 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; /** @} */ /** 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; 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) 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); } 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