Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ lib\app|u error.c | 49 | error:预期为'='''''';asm&x27;或'__属性';在'之前;无效';北欧半示例_C++_C_Nrf51 - Fatal编程技术网

C++ lib\app|u error.c | 49 | error:预期为'='''''';asm&x27;或'__属性';在'之前;无效';北欧半示例

C++ lib\app|u error.c | 49 | error:预期为'='''''';asm&x27;或'__属性';在'之前;无效';北欧半示例,c++,c,nrf51,C++,C,Nrf51,我尝试使用nordic semiconductor示例演示如何使用按钮处理库: 编译器给了我标题中的错误。我正试图找到丢失的昏迷或分号,但我看不出有任何错误 app_error.c /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. * * The information contained herein is property of Nordic Semiconductor ASA. * Terms and c

我尝试使用nordic semiconductor示例演示如何使用按钮处理库: 编译器给了我标题中的错误。我正试图找到丢失的昏迷或分号,但我看不出有任何错误

app_error.c

/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
 *
 * The information contained herein is property of Nordic Semiconductor ASA.
 * Terms and conditions of usage are described in detail in NORDIC
 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
 *
 * Licensees are granted free, non-transferable use of the information. NO
 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
 * the file.
 *
 */

/** @file
 *
 * @defgroup app_error Common application error handler
 * @{
 * @ingroup app_common
 *
 * @brief Common application error handler.
 */

#include "nrf.h"
#include "app_error.h"
#include "compiler_abstraction.h"
#include "nordic_common.h"
#ifdef DEBUG
#include "bsp.h"

/* global error variables - in order to prevent removal by optimizers */
uint32_t m_error_code;
uint32_t m_line_num;
const uint8_t * m_p_file_name;
#endif

/**@brief Function for error handling, which is called when an error has occurred.
 *
 * @warning This handler is an example only and does not fit a final product. You need to analyze
 *          how your product is supposed to react in case of error.
 *
 * @param[in] error_code  Error code supplied to the handler.
 * @param[in] line_num    Line number where the handler is called.
 * @param[in] p_file_name Pointer to the file name.
 *
 * Function is implemented as weak so that it can be overwritten by custom application error handler
 * when needed.
 */

/*lint -save -e14 */
__WEAK void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name)
{
    // On assert, the system can only recover with a reset.
#ifndef DEBUG
    NVIC_SystemReset();
#else

#ifdef BSP_DEFINES_ONLY
    LEDS_ON(LEDS_MASK);
#else
    UNUSED_VARIABLE(bsp_indication_set(BSP_INDICATE_FATAL_ERROR));
    // This call can be used for debug purposes during application development.
    // @note CAUTION: Activating this code will write the stack to flash on an error.
    //                This function should NOT be used in a final product.
    //                It is intended STRICTLY for development/debugging purposes.
    //                The flash write will happen EVEN if the radio is active, thus interrupting
    //                any communication.
    //                Use with care. Uncomment the line below to use.
    //ble_debug_assert_handler(error_code, line_num, p_file_name);
#endif // BSP_DEFINES_ONLY

    m_error_code = error_code;
    m_line_num = line_num;
    m_p_file_name = p_file_name;

    UNUSED_VARIABLE(m_error_code);
    UNUSED_VARIABLE(m_line_num);
    UNUSED_VARIABLE(m_p_file_name);
    __disable_irq();
    while(1) ;
#endif // DEBUG
}
/*lint -restore */
应用程序错误.h

/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
 *
 * The information contained herein is property of Nordic Semiconductor ASA.
 * Terms and conditions of usage are described in detail in NORDIC
 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
 *
 * Licensees are granted free, non-transferable use of the information. NO
 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
 * the file.
 *
 */

/** @file
 *
 * @defgroup app_error Common application error handler
 * @{
 * @ingroup app_common
 *
 * @brief Common application error handler and macros for utilizing a common error handler.
 */

#ifndef APP_ERROR_H__
#define APP_ERROR_H__

#include <stdint.h>
#include <stdbool.h>
#include "nrf_error.h"

/**@brief Function for error handling, which is called when an error has occurred.
 *
 * @param[in] error_code  Error code supplied to the handler.
 * @param[in] line_num    Line number where the handler is called.
 * @param[in] p_file_name Pointer to the file name.
 */
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name);

/**@brief Macro for calling error handler function.
 *
 * @param[in] ERR_CODE Error code supplied to the error handler.
 */
#ifdef DEBUG
#define APP_ERROR_HANDLER(ERR_CODE)                         \
    do                                                      \
    {                                                       \
        app_error_handler((ERR_CODE), __LINE__, (uint8_t*) __FILE__);  \
    } while (0)
#else
#define APP_ERROR_HANDLER(ERR_CODE)                         \
    do                                                      \
    {                                                       \
        app_error_handler((ERR_CODE), 0, 0);  \
    } while (0)
#endif
/**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS.
 *
 * @param[in] ERR_CODE Error code supplied to the error handler.
 */
#define APP_ERROR_CHECK(ERR_CODE)                           \
    do                                                      \
    {                                                       \
        const uint32_t LOCAL_ERR_CODE = (ERR_CODE);         \
        if (LOCAL_ERR_CODE != NRF_SUCCESS)                  \
        {                                                   \
            APP_ERROR_HANDLER(LOCAL_ERR_CODE);              \
        }                                                   \
    } while (0)

/**@brief Macro for calling error handler function if supplied boolean value is false.
 *
 * @param[in] BOOLEAN_VALUE Boolean value to be evaluated.
 */
#define APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE)                   \
    do                                                        \
    {                                                         \
        const uint32_t LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \
        if (!LOCAL_BOOLEAN_VALUE)                             \
        {                                                     \
            APP_ERROR_HANDLER(0);                             \
        }                                                     \
    } while (0)

#endif // APP_ERROR_H__

/** @} */
/*版权所有(c)2013北欧半导体。版权所有。
*
*本文所含信息为北欧半导体ASA的财产。
*北欧语中详细描述了使用条款和条件
*半导体标准软件许可协议。
*
*被许可人可以免费、不可转让地使用这些信息。不
*提供任何形式的担保。此标题不得从中删除
*档案。
*
*/
/**@file
*
*@defgroup-app\u错误通用应用程序错误处理程序
* @{
*@ingroup应用程序\u通用
*
*@brief公共应用程序错误处理程序和用于使用公共错误处理程序的宏。
*/
#ifndef应用程序错误__
#定义应用程序错误__
#包括
#包括
#包括“nrf_error.h”
/**@用于错误处理的简短函数,在发生错误时调用。
*
*@param[in]error\u code提供给处理程序的错误代码。
*@param[in]line_num调用处理程序的行号。
*@param[in]p_file_name指向文件名的指针。
*/
无效应用程序错误处理程序(uint32错误代码、uint32行编号、常量uint8*p文件名);
/**@用于调用错误处理函数的简短宏。
*
*@param[in]ERR_CODE提供给错误处理程序的错误代码。
*/
#ifdef调试
#定义应用程序错误处理程序(错误代码)\
做\
{                                                       \
应用程序错误处理程序((错误代码),(行代码),(uint8\t*)文件)\
}而(0)
#否则
#定义应用程序错误处理程序(错误代码)\
做\
{                                                       \
应用程序错误处理程序((错误代码),0,0)\
}而(0)
#恩迪夫
/**@如果提供的错误代码不是NRF_SUCCESS,则调用错误处理函数的简短宏。
*
*@param[in]ERR_CODE提供给错误处理程序的错误代码。
*/
#定义应用程序错误检查(错误代码)\
做\
{                                                       \
const uint32_t LOCAL_ERR_CODE=(ERR_CODE)\
如果(本地错误代码!=NRF成功)\
{                                                   \
应用程序错误处理程序(本地错误代码)\
}                                                   \
}而(0)
/**@用于在提供的布尔值为false时调用错误处理程序函数的简短宏。
*
*@param[in]布尔值要计算的布尔值。
*/
#定义应用程序错误检查布尔值(布尔值)\
做\
{                                                         \
const uint32_t LOCAL_BOOLEAN_VALUE=(BOOLEAN_VALUE)\
if(!局部布尔值)\
{                                                     \
应用程序错误处理程序(0)\
}                                                     \
}而(0)
#endif//应用程序错误__
/** @} */
main.c

**********************************************************************/

#include "nrf.h"
#include "ble.h"

#include <stdbool.h>
#include <string.h>
#include "app_button.h"
#include "boards.h"
#include "app_gpiote.h"
#include "app_timer.h"
#include "pca10028.h"



#define APP_TIMER_PRESCALER             0  // Value of the RTC1 PRESCALER register.
#define APP_TIMER_MAX_TIMERS            1  // Maximum number of simultaneously created timers.
#define APP_TIMER_OP_QUEUE_SIZE         2  // Size of timer operation queues.
#define BUTTON_DEBOUNCE_DELAY           50 // Delay from a GPIOTE event until a button is reported as pushed.
#define APP_GPIOTE_MAX_USERS            1  // Maximum number of users of the GPIOTE handler.


/*
 * Handler to be called when button is pushed.
 * param[in]   pin_no           The pin number where the event is genereated
 * param[in]   button_action    Is the button pushed or released
 */
static void button_handler(uint8_t pin_no, uint8_t button_action)
{
    if(button_action == APP_BUTTON_PUSH)
    {
        switch(pin_no)
        {
            case BUTTON_1:
                nrf_gpio_pin_toggle(LED_1);
                break;
            case BUTTON_2:
                nrf_gpio_pin_toggle(LED_2);
                break;
            case BUTTON_3:
                nrf_gpio_pin_toggle(LED_3);
                break;
            case BUTTON_4:
                nrf_gpio_pin_toggle(LED_4);
                break;
            default:
                break;
        }
    }
}

/**
 * Initialize the clock.
 */
void init_clock()
{
    NRF_CLOCK->LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART    = 1;
    while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0); // Wait for clock to start
}

/**
 * Initialize all four LEDs on the nRF51 DK.
 */
void init_leds()
{
    nrf_gpio_cfg_output(LED_1);
    nrf_gpio_cfg_output(LED_2);
    nrf_gpio_cfg_output(LED_3);
    nrf_gpio_cfg_output(LED_4);
    nrf_gpio_pin_set(LED_1);
    nrf_gpio_pin_set(LED_2);
    nrf_gpio_pin_set(LED_3);
    nrf_gpio_pin_set(LED_4);
}

/**
 * Function for application main entry.
 */
int main(void)
{
    init_leds();
    init_clock();

    uint32_t err_code;

    // Button configuration structure.
    static app_button_cfg_t p_button[] = {  {BUTTON_1, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                            {BUTTON_2, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                            {BUTTON_3, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                            {BUTTON_4, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}};

    // Macro for initializing the application timer module.
    // It will handle dimensioning and allocation of the memory buffer required by the timer, making sure that the buffer is correctly aligned. It will also connect the timer module to the scheduler (if specified).
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL);

    // Macro for initializing the GPIOTE module.
    // It will handle dimensioning and allocation of the memory buffer required by the module, making sure that the buffer is correctly aligned.
    APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);

    // Initializing the buttons.
    err_code = app_button_init(p_button, sizeof(p_button) / sizeof(p_button[0]), BUTTON_DEBOUNCE_DELAY);
    APP_ERROR_CHECK(err_code);

    // Enabling the buttons.
    err_code = app_button_enable();
    APP_ERROR_CHECK(err_code);

    while(true)
    {
        // Do nothing.
    }
}
**********************************************************************/
#包括“nrf.h”
#包括“ble.h”
#包括
#包括
#包括“app_button.h”
#包括“boards.h”
#包括“appgpiote.h”
#包括“app_timer.h”
#包括“pca10028.h”
#定义RTC1预分频器寄存器的应用定时器预分频器0//值。
#定义APP\u TIMER\u MAX\u TIMER 1//同时创建的计时器的最大数量。
#定义应用程序\计时器\操作\队列\大小2//计时器操作队列的大小。
#定义按钮解除抖动延迟50//GPIOTE事件的延迟,直到按钮被报告为按下。
#定义APP_GPIOTE_MAX_USERS 1//GPIOTE处理程序的最大用户数。
/*
*按下按钮时要调用的处理程序。
*param[in]pin_no生成事件的pin编号
*参数[输入]按钮\按钮的动作是按下或释放按钮
*/
静态无效按钮\u处理程序(uint8\u t引脚\u编号,uint8\u t按钮\u操作)
{
如果(按钮动作==应用按钮按下)
{
开关(引脚号)
{
案例按钮1:
nrf_gpio_引脚_开关(LED_1);
打破
外壳按钮2:
nrf_gpio_引脚_开关(LED_2);
打破
案例按钮3:
nrf_gpio_引脚_开关(LED_3);
打破
箱子按钮4:
nrf_gpio_引脚_开关(LED_4);
打破
违约:
打破
}
}
}
/**
*初始化时钟。
*/
void init_clock()
{
NRF_CLOCK->LFCLKSRC=(CLOCK_LFCLKSRC_SRC_Xtal EVENTS_LFCLKSTARTED=0;
NRF_CLOCK->TASKS_LFCLKSTART=1;
while(NRF_CLOCK->EVENTS_LFCLKSTARTED==0);//等待时钟启动
}
/**
*初始化nRF51 DK上的所有四个LED。
*/
void init_发光二极管()
{
nrf_gpio_cfg_输出(LED_1);
nrf_gpio_cfg_输出(LED_2);
nrf_gpio_cfg_输出(LED_3);
nrf_gpio_cfg_输出(LED_4);
nrf_gpio_引脚组(LED_1);
nrf_gpio_引脚组(LED_2);
nrf_gpio_引脚组(LED_3);
nrf_gpio_引脚组(LED_4);
}
/**
*应用程序主条目的函数。
*/
内部主(空)
{
初始化发光二极管();
初始化时钟();
uint32错误代码;
//按钮配置结构。
静态应用程序按钮\u cfg\u t p\u按钮[]={{按钮\u 1,应用程序按钮\u活动\u低位,NRF\u GPIO\u引脚\u上拉,按钮\u处理器},
__WEAK void app_error_handler(/*...*/)