-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
Describe the bug
A clear and concise description of what the bug is.
What have you tried to diagnose or workaround this issue?
To Reproduce
Steps to reproduce the behavior:
- mkdir build; cd build
- cmake -DBOARD=board_xyz
- make
- See error
Expected behavior
When the project with ring buffer was built, it reported the following error:
undefined reference to "ring_buf_item_put"
Impact
Logs and console output
undefined reference to `ring_buf_item_put'
collect2: error: ld returned 1 exit status
Environment (please complete the following information):
OS - Windows
Toolchain: Zephyr SDK
Additional context
Add any other context about the problem here.
#include <zephyr.h>
#include <device.h>
#include <drivers/gpio.h>
#include <sys/printk.h>
#include <sys/__assert.h>
#include <string.h>
#include <sys/ring_buffer.h>
/* size of stack area used by each thread */
#define STACKSIZE 1024
/* scheduling priority used by each thread */
#define PRIORITY 7
#define RB_DATA_TYPE1 ( 0x01 )
#define RB_DATA_TYPE2 ( 0x02 )
#define RB_DATA_TYPE1_VAL ( 0x11 )
#define RB_DATA_TYPE2_VAL ( 0x22 )
RING_BUF_ITEM_DECLARE_POW2(my_ring_buf, 4);
static void producer_thread( void);
K_THREAD_DEFINE(producer_thread_id, STACKSIZE, producer_thread, NULL, NULL, NULL,
PRIORITY, 0, 0);
static void producer_thread(void)
{
int ret;
uint32_t count = 0;
uint32_t data;
while (1) {
printk( "Producer: putting data...\n" );
if( 0x1 & count ) {
ret = ring_buf_item_put( &my_ring_buf, RB_DATA_TYPE1, RB_DATA_TYPE1_VAL, &count, 1 );
} else {
ret = ring_buf_item_put( &my_ring_buf, RB_DATA_TYPE2, RB_DATA_TYPE2_VAL, &count, 1 );
}
if ( 0 != ret ) {
printk( "No memory available\r\n" );
}
k_msleep( 5000 );
}
}