<commit_before>/*
 * Copyright (C) 2014 <NAME> <<EMAIL>>
 */

#include <uavcan_stm32/clock.hpp>
#include <uavcan_stm32/thread.hpp>
#include "internal.hpp"

#if UAVCAN_STM32_TIMER_NUMBER

#include <cassert>
#include <cmath>

/*
 * Timer instance
 */
# if (UAVCAN_STM32_CHIBIOS && CH_KERNEL_MAJOR == 2) || UAVCAN_STM32_BAREMETAL || UAVCAN_STM32_FREERTOS
#  define TIMX                    UAVCAN_STM32_GLUE2(TIM, UAVCAN_STM32_TIMER_NUMBER)
#  define TIMX_IRQn               UAVCAN_STM32_GLUE3(TIM, UAVCAN_STM32_TIMER_NUMBER, _IRQn)
#  define TIMX_INPUT_CLOCK        STM32_TIMCLK1
# endif

# if (UAVCAN_STM32_CHIBIOS && CH_KERNEL_MAJOR == 3)
#  define TIMX                    UAVCAN_STM32_GLUE2(STM32_TIM, UAVCAN_STM32_TIMER_NUMBER)
#  define TIMX_IRQn               UAVCAN_STM32_GLUE3(STM32_TIM, UAVCAN_STM32_TIMER_NUMBER, _NUMBER)
#  define TIMX_IRQHandler         UAVCAN_STM32_GLUE3(STM32_TIM, UAVCAN_STM32_TIMER_NUMBER, _HANDLER)
#  define TIMX_INPUT_CLOCK        STM32_TIMCLK1
# else
#  define TIMX_IRQHandler         UAVCAN_STM32_GLUE3(TIM, UAVCAN_STM32_TIMER_NUMBER, _IRQHandler)
# endif

# if UAVCAN_STM32_NUTTX
#  define TIMX                    UAVCAN_STM32_GLUE3(STM32_TIM, UAVCAN_STM32_TIMER_NUMBER, _BASE)
#  define  TMR_REG(o)              (TIMX + (o))
#  define TIMX_INPUT_CLOCK         STM32_TIM27_FREQUENCY

#  define TIMX_IRQn                UAVCAN_STM32_GLUE2(STM32_IRQ_TIM, UAVCAN_STM32_TIMER_NUMBER)
# endif

# if UAVCAN_STM32_TIMER_NUMBER >= 2 && UAVCAN_STM32_TIMER_NUMBER <= 7
#  define TIMX_RCC_ENR           RCC->APB1ENR
#  define TIMX_RCC_RSTR          RCC->APB1RSTR
#  define TIMX_RCC_ENR_MASK      UAVCAN_STM32_GLUE3(RCC_APB1ENR_TIM,  UAVCAN_STM32_TIMER_NUMBER, EN)
#  define TIMX_RCC_RSTR_MASK     UAVCAN_STM32_GLUE3(RCC_APB1RSTR_TIM, UAVCAN_STM32_TIMER_NUMBER, RST)
# else
#  error "This UAVCAN_STM32_TIMER_NUMBER is not supported yet"
# endif

# if (TIMX_INPUT_CLOCK % 1000000) != 0
#  error "No way, timer clock must be divisible to 1e6. FIXME!"
# endif

extern "C" UAVCAN_STM32_IRQ_HANDLER(TIMX_IRQHandler);

namespace uavcan_stm32
{
namespace clock
{
namespace<commit_msg>This is needed to work with the latest upstream nuttx 7.16+<commit_after>/*
 * Copyright (C) 2014 <NAME> <<EMAIL>>
 */

#include <uavcan_stm32/clock.hpp>
#include <uavcan_stm32/thread.hpp>
#include "internal.hpp"

#if UAVCAN_STM32_TIMER_NUMBER

#include <cassert>
#include <cmath>

/*
 * Timer instance
 */
# if (UAVCAN_STM32_CHIBIOS && CH_KERNEL_MAJOR == 2) || UAVCAN_STM32_BAREMETAL || UAVCAN_STM32_FREERTOS
#  define TIMX                    UAVCAN_STM32_GLUE2(TIM, UAVCAN_STM32_TIMER_NUMBER)
#  define TIMX_IRQn               UAVCAN_STM32_GLUE3(TIM, UAVCAN_STM32_TIMER_NUMBER, _IRQn)
#  define TIMX_INPUT_CLOCK        STM32_TIMCLK1
# endif

# if (UAVCAN_STM32_CHIBIOS && CH_KERNEL_MAJOR == 3)
#  define TIMX                    UAVCAN_STM32_GLUE2(STM32_TIM, UAVCAN_STM32_TIMER_NUMBER)
#  define TIMX_IRQn               UAVCAN_STM32_GLUE3(STM32_TIM, UAVCAN_STM32_TIMER_NUMBER, _NUMBER)
#  define TIMX_IRQHandler         UAVCAN_STM32_GLUE3(STM32_TIM, UAVCAN_STM32_TIMER_NUMBER, _HANDLER)
#  define TIMX_INPUT_CLOCK        STM32_TIMCLK1
# else
#  define TIMX_IRQHandler         UAVCAN_STM32_GLUE3(TIM, UAVCAN_STM32_TIMER_NUMBER, _IRQHandler)
# endif

# if UAVCAN_STM32_NUTTX
#  define TIMX                    UAVCAN_STM32_GLUE3(STM32_TIM, UAVCAN_STM32_TIMER_NUMBER, _BASE)
#  define  TMR_REG(o)              (TIMX + (o))
#  define TIMX_INPUT_CLOCK         UAVCAN_STM32_GLUE3(STM32_APB1_TIM, UAVCAN_STM32_TIMER_NUMBER, _CLKIN)

#  define TIMX_IRQn                UAVCAN_STM32_GLUE2(STM32_IRQ_TIM, UAVCAN_STM32_TIMER_NUMBER)
# endif

# if UAVCAN_STM32_TIMER_NUMBER >= 2 && UAVCAN_STM32_TIMER_NUMBER <= 7
#  define TIMX_RCC_ENR           RCC->APB1ENR
#  define TIMX_RCC_RSTR          RCC->APB1RSTR
#  define TIMX_RCC_ENR_MASK      UAVCAN_STM32_GLUE3(RCC_APB1ENR_TIM,  UAVCAN_STM32_TIMER_NUMBER, EN)
#  define TIMX_RCC_RSTR_MASK     UAVCAN_STM32_GLUE3(RCC_APB1RSTR_TIM, UAVCAN_STM32_TIMER_NUMBER, RST)
# else
#  error "This UAVCAN_STM32_TIMER_NUMBER is not supported yet"
# endif

# if (TIMX_INPUT_CLOCK % 1000000) != 0
#  error "No way, timer clock must be divisible to 1e6. FIXME!"
# endif

extern "C" UAVCAN_STM32_IRQ_HANDLER(TIMX_IRQHandler);

namespace uavcan_stm32
{
namespace clock
{
namespace
{'fraction_non_alphanumeric': 0.07635009310986965, 'fraction_numerical': 0.05656424581005587, 'mean_word_length': 4.103325415676959, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '672298', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1779, 'n_words': 291}