Hey all, I am using an NRF52 DK and am trying to combine the 'pwm' and 'ant broadcast' examples. Both examples compile fine on their own, but when I try to combine I am getting these two errors:
Output/ant_broadcast_tx_pca10040_s212 Release/Obj/app_pwm.o: In function `app_pwm_init':
undefined reference to `nrf_drv_ppi_init'
I don't understand what the first one is but the second one seems like it is not finding the library... I made sure PPI is turned on in sdk_config.h and that it is included in the header and makefile... Also don't know if it matters but I am working in Segger Embedded Studio using S212 SoftDevice. I have included everything I seemed to have needed in the header and added all to the makefile; please advise.
/** * This software is subject to the ANT+ Shared Source License * www.thisisant.com/swlicenses * Copyright (c) Dynastream Innovations, Inc. 2014 * All rights reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * 1) Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * 2) Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * 3) Neither the name of Dynastream nor the names of its * contributors may be used to endorse or promote products * derived from this software without specific prior * written permission. * * The following actions are prohibited: * 1) Redistribution of source code containing the ANT+ Network * Key. The ANT+ Network Key is available to ANT+ Adopters. * Please refer to http://thisisant.com to become an ANT+ * Adopter and access the key. * * 2) Reverse engineering, decompilation, and/or disassembly of * software provided in binary form under this license. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE HEREBY * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; DAMAGE TO ANY DEVICE, LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. SOME STATES DO NOT ALLOW * THE EXCLUSION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE * ABOVE LIMITATIONS MAY NOT APPLY TO YOU. * */ /**@file * @defgroup nrf_ant_broadcast_tx_example ANT Broadcast TX Example * @{ * @ingroup nrf_ant_broadcast * * @brief Example of basic ANT Broadcast TX. * * Before compiling this example for NRF52, complete the following steps: * - Download the S212 SoftDevice from <a href="https://www.thisisant.com/developer/components/nrf52832" target="_blank">thisisant.com</a>. * - Extract the downloaded zip file and copy the S212 SoftDevice headers to <tt>\<InstallFolder\>/components/softdevice/s212/headers</tt>. * If you are using Keil packs, copy the files into a @c headers folder in your example folder. * - Make sure that @ref ANT_LICENSE_KEY in @c nrf_sdm.h is uncommented. */ #include <stdbool.h> #include <stdint.h> #include <string.h> #include "nrf.h" #include "bsp.h" #include "hardfault.h" #include "app_error.h" #include "app_timer.h" #include "nrf_sdh.h" #include "nrf_sdh_ant.h" #include "nrf_pwr_mgmt.h" #include "ant_interface.h" #include "ant_parameters.h" #include "ant_channel_config.h" #include "nrf_delay.h" #include "app_pwm.h" #include "nrfx_ppi.h" #include "nrf_log.h" #include "nrf_log_ctrl.h" #include "nrf_log_default_backends.h" #define APP_ANT_OBSERVER_PRIO 1 /**< Application's ANT observer priority. You shouldn't need to modify this value. */ /**@brief Function for setting payload for ANT message and sending it. */ void ant_message_send(void) { uint8_t message_payload[ANT_STANDARD_DATA_PAYLOAD_SIZE]; static uint8_t counter = 1u; memset(message_payload, 0, ANT_STANDARD_DATA_PAYLOAD_SIZE); // Assign a new value to the broadcast data. message_payload[ANT_STANDARD_DATA_PAYLOAD_SIZE - 1] = counter; // Broadcast the data. ret_code_t err_code = sd_ant_broadcast_message_tx(BROADCAST_CHANNEL_NUMBER, ANT_STANDARD_DATA_PAYLOAD_SIZE, message_payload); APP_ERROR_CHECK(err_code); counter++; } /**@brief Function for handling a ANT stack event. * * @param[in] p_ant_evt ANT stack event. * @param[in] p_context Context. */ static void ant_evt_handler(ant_evt_t * p_ant_evt, void * p_context) { ret_code_t err_code; nrf_pwr_mgmt_feed(); if (p_ant_evt->channel == BROADCAST_CHANNEL_NUMBER) { switch (p_ant_evt->event) { case EVENT_TX: ant_message_send(); err_code = bsp_indication_set(BSP_INDICATE_SENT_OK); APP_ERROR_CHECK(err_code); break; default: break; } } } NRF_SDH_ANT_OBSERVER(m_ant_observer, APP_ANT_OBSERVER_PRIO, ant_evt_handler, NULL); /**@brief Function for the Timer and BSP initialization. */ static void utils_setup(void) { ret_code_t err_code = app_timer_init(); APP_ERROR_CHECK(err_code); err_code = bsp_init(BSP_INIT_LEDS, NULL); APP_ERROR_CHECK(err_code); err_code = nrf_pwr_mgmt_init(); APP_ERROR_CHECK(err_code); } /**@brief Function for ANT stack initialization. */ static void softdevice_setup(void) { ret_code_t err_code = nrf_sdh_enable_request(); APP_ERROR_CHECK(err_code); ASSERT(nrf_sdh_is_enabled()); err_code = nrf_sdh_ant_enable(); APP_ERROR_CHECK(err_code); } /**@brief Function for setting up the ANT module to be ready for TX broadcast. */ static void ant_channel_tx_broadcast_setup(void) { ant_channel_config_t broadcast_channel_config = { .channel_number = BROADCAST_CHANNEL_NUMBER, .channel_type = CHANNEL_TYPE_MASTER, .ext_assign = 0x00, .rf_freq = RF_FREQ, .transmission_type = CHAN_ID_TRANS_TYPE, .device_type = CHAN_ID_DEV_TYPE, .device_number = CHAN_ID_DEV_NUM, .channel_period = CHAN_PERIOD, .network_number = ANT_NETWORK_NUM, }; ret_code_t err_code = ant_channel_init(&broadcast_channel_config); APP_ERROR_CHECK(err_code); // Fill tx buffer for the first frame. ant_message_send(); // Open channel. err_code = sd_ant_channel_open(BROADCAST_CHANNEL_NUMBER); APP_ERROR_CHECK(err_code); } /** *@brief Function for initializing logging. */ static void log_init(void) { ret_code_t err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); NRF_LOG_DEFAULT_BACKENDS_INIT(); } /**@brief Function for application main entry. Does not return. */ /** PWM initialzing crap */ APP_PWM_INSTANCE(PWM1,2); // Create the instance "PWM1" using TIMER1. static volatile bool ready_flag; // A flag indicating PWM status. void pwm_ready_callback(uint32_t pwm_id) // PWM callback function { ready_flag = true; } int main(void) { log_init(); utils_setup(); softdevice_setup(); ant_channel_tx_broadcast_setup(); NRF_LOG_INFO("ANT Broadcast TX example started."); ret_code_t err_code; /* 2-channel PWM, 200Hz, output on DK LED pins. */ app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_2CH(2000L, BSP_LED_2, BSP_LED_3); /* Switch the polarity of the second channel. */ pwm1_cfg.pin_polarity[1] = APP_PWM_POLARITY_ACTIVE_HIGH; /* Initialize and enable PWM. */ err_code = app_pwm_init(&PWM1,&pwm1_cfg,pwm_ready_callback); APP_ERROR_CHECK(err_code); app_pwm_enable(&PWM1); uint32_t value; while (true) { for (uint8_t i = 0; i < 40; ++i) { value = (i < 20) ? (i * 5) : (100 - (i - 20) * 5); ready_flag = false; /* Set the duty cycle - keep trying until PWM is ready... */ while (app_pwm_channel_duty_set(&PWM1, 0, value) == NRF_ERROR_BUSY); /* ... or wait for callback. */ while (!ready_flag); APP_ERROR_CHECK(app_pwm_channel_duty_set(&PWM1, 1, value)); nrf_delay_ms(25); } NRF_LOG_FLUSH(); nrf_pwr_mgmt_run(); } // Main loop. /** for (;;) { NRF_LOG_FLUSH(); nrf_pwr_mgmt_run(); } */ } /** *@} **/
Included are my main file and sdk_config.
Thanks,
Vkryvor