pkarashchenko commented on code in PR #6715: URL: https://github.com/apache/incubator-nuttx/pull/6715#discussion_r930744441
########## arch/arm/src/stm32wb/stm32wb_mbox_list.h: ########## @@ -0,0 +1,144 @@ +/**************************************************************************** + * arch/arm/src/stm32wb/stm32wb_mbox_list.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_STM32WB_STM32WB_MBOX_LIST_H +#define __ARCH_ARM_SRC_STM32WB_STM32WB_MBOX_LIST_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* This list implementation is similar to list_node, but prev and next + * fields are at opposite places and the struct is packed. Also there is + * a new list_moveall function. + */ + +begin_packed_struct struct stm32wb_mbox_list_s +{ + struct stm32wb_mbox_list_s *next; + struct stm32wb_mbox_list_s *prev; +} end_packed_struct; + +typedef struct stm32wb_mbox_list_s stm32wb_mbox_list_t; + +/**************************************************************************** + * Inline Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32wb_mbox_list_initialize + * + * Description: + * Initialize internal fields. + * + ****************************************************************************/ + +static inline void stm32wb_mbox_list_initialize(stm32wb_mbox_list_t *list) +{ + list->prev = list; + list->next = list; +} + +/**************************************************************************** + * Name: stm32wb_mbox_list_add_tail + * + * Description: + * Add new node at the end of the list. + * + ****************************************************************************/ + +static inline void stm32wb_mbox_list_add_tail(stm32wb_mbox_list_t *list, + stm32wb_mbox_list_t *item) +{ + item->prev = list->prev; + item->next = list; + list->prev->next = item; + list->prev = item; +} + +/**************************************************************************** + * Name: stm32wb_mbox_list_remove_head + * + * Description: + * Remove and return first node from the list head (if any). + * + ****************************************************************************/ + +static inline stm32wb_mbox_list_t * +stm32wb_mbox_list_remove_head(stm32wb_mbox_list_t *list) +{ + if (list->next != list) + { + stm32wb_mbox_list_t *item = list->next; + item->next->prev = item->prev; + item->prev->next = item->next; + item->prev = NULL; + item->next = NULL; + return item; + } + else + { + return NULL; + } +} + +/**************************************************************************** + * Name: stm32wb_mbox_list_is_empty + * + * Description: + * Check if the list is empty. + * + ****************************************************************************/ + +static inline bool stm32wb_mbox_list_is_empty(stm32wb_mbox_list_t *list) +{ + return (list->next == list) ? true : false; Review Comment: ```suggestion return (list->next == list); ``` ########## arch/arm/src/stm32wb/stm32wb_ipcc.h: ########## @@ -71,6 +72,109 @@ void stm32wb_ipccreset(void); void stm32wb_ipccenable(void); +/**************************************************************************** + * Inline Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32wb_ipcc_rxactive + * + * Description: + * Check channel receive active flag. + * + ****************************************************************************/ + +static inline bool stm32wb_ipcc_rxactive(uint8_t chan) +{ + return (getreg32(STM32WB_IPCC_C2TOC1SR) & IPCC_C2TOC1SR_BIT(chan)) != 0; +} + +/**************************************************************************** + * Name: stm32wb_ipcc_txactive + * + * Description: + * Check channel transmit active flag. + * + ****************************************************************************/ + +static inline bool stm32wb_ipcc_txactive(uint8_t chan) +{ + return (getreg32(STM32WB_IPCC_C1TOC2SR) & IPCC_C1TOC2SR_BIT(chan)) != 0; +} + +/**************************************************************************** + * Name: stm32wb_ipcc_settxactive + * + * Description: + * Set channel transmit active flag. + * + ****************************************************************************/ + +static inline void stm32wb_ipcc_settxactive(uint8_t chan) +{ + putreg32(IPCC_C1SCR_SET_BIT(chan), STM32WB_IPCC_C1SCR); +} + +/**************************************************************************** + * Name: stm32wb_ipcc_masktxf + * + * Description: + * Mask channel transmit free interrupt. + * + ****************************************************************************/ + +static inline void stm32wb_ipcc_masktxf(uint8_t chan) +{ + uint32_t regval = getreg32(STM32WB_IPCC_C1MR); + regval |= IPCC_C1MR_FM_BIT(chan); + putreg32(regval, STM32WB_IPCC_C1MR); +} + +/**************************************************************************** + * Name: stm32wb_ipcc_unmasktxf + * + * Description: + * Unmask channel transmit free interrupt. + * + ****************************************************************************/ + +static inline void stm32wb_ipcc_unmasktxf(uint8_t chan) +{ + uint32_t regval = getreg32(STM32WB_IPCC_C1MR); + regval &= ~IPCC_C1MR_FM_BIT(chan); + putreg32(regval, STM32WB_IPCC_C1MR); +} + +/**************************************************************************** + * Name: stm32wb_ipcc_maskrxo + * + * Description: + * Mask channel receive occupied interrupt. + * + ****************************************************************************/ + +static inline void stm32wb_ipcc_maskrxo(uint8_t chan) +{ + uint32_t regval = getreg32(STM32WB_IPCC_C1MR); + regval |= IPCC_C1MR_OM_BIT(chan); + putreg32(regval, STM32WB_IPCC_C1MR); +} + +/**************************************************************************** + * Name: stm32wb_ipcc_maskrxo + * + * Description: + * Unmask channel receive occupied interrupt. + * + ****************************************************************************/ + +static inline void stm32wb_ipcc_unmaskrxo(uint8_t chan) +{ + uint32_t regval = getreg32(STM32WB_IPCC_C1MR); + regval &= ~IPCC_C1MR_OM_BIT(chan); + putreg32(regval, STM32WB_IPCC_C1MR); Review Comment: code is good, but you may consider using `modreg32` instead of `getreg32` + `putreg32`. That is basically the same, but will produce less lines of code -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org