docs: convert to using newly introduced integer sized types

Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I731cc91517436685836023cbda34f894586a54bc
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2017-04-19 13:02:23 -05:00
commit 83a5990185
13 changed files with 61 additions and 61 deletions

View file

@ -205,7 +205,7 @@ with a different interrupt line. In `drivers/subsystem/subsystem_my_driver.h`:
typedef void (*my_driver_config_irq_t)(struct device *device); typedef void (*my_driver_config_irq_t)(struct device *device);
struct my_driver_config { struct my_driver_config {
uint32_t base_addr; u32_t base_addr;
my_driver_config_irq_t config_func; my_driver_config_irq_t config_func;
}; };

View file

@ -253,7 +253,7 @@ portion of the message isn't used.
while (1) { while (1) {
/* generate random value to send */ /* generate random value to send */
uint32_t random_value = sys_rand32_get(); u32_t random_value = sys_rand32_get();
/* prepare to send empty message */ /* prepare to send empty message */
send_msg.info = random_value; send_msg.info = random_value;

View file

@ -74,9 +74,9 @@ that is capable of holding 10 items, each of which is 12 bytes long.
.. code-block:: c .. code-block:: c
struct data_item_type { struct data_item_type {
uint32_t field1; u32_t field1;
uint32_t field2; u32_t field2;
uint32_t field3; u32_t field3;
}; };
char __aligned(4) my_msgq_buffer[10 * sizeof(data_item_type)]; char __aligned(4) my_msgq_buffer[10 * sizeof(data_item_type)];

View file

@ -63,7 +63,7 @@ up to ten 32-bit data values.
#define MAX_ITEMS 10 #define MAX_ITEMS 10
uint32_t my_stack_array[MAX_ITEMS]; u32_t my_stack_array[MAX_ITEMS];
struct k_stack my_stack; struct k_stack my_stack;
k_stack_init(&my_stack, my_stack_array, MAX_ITEMS); k_stack_init(&my_stack, my_stack_array, MAX_ITEMS);
@ -98,7 +98,7 @@ in a stack.
/* save address of each data structure in a stack */ /* save address of each data structure in a stack */
for (int i = 0; i < MAX_ITEMS; i++) { for (int i = 0; i < MAX_ITEMS; i++) {
k_stack_push(&my_stack, (uint32_t)&my_buffers[i]); k_stack_push(&my_stack, (u32_t)&my_buffers[i]);
} }
Popping from a Stack Popping from a Stack
@ -115,7 +115,7 @@ its address back on the stack to allow the data structure to be reused.
struct my_buffer_type *new_buffer; struct my_buffer_type *new_buffer;
k_stack_pop(&buffer_stack, (uint32_t *)&new_buffer, K_FOREVER); k_stack_pop(&buffer_stack, (u32_t *)&new_buffer, K_FOREVER);
new_buffer->field1 = ... new_buffer->field1 = ...
Suggested Uses Suggested Uses

View file

@ -84,7 +84,7 @@ is capable of holding 64 words of data and metadata information.
struct my_struct { struct my_struct {
struct ring_buf rb; struct ring_buf rb;
uint32_t buffer[MY_RING_BUF_SIZE]; u32_t buffer[MY_RING_BUF_SIZE];
... ...
}; };
struct my_struct ms; struct my_struct ms;
@ -121,7 +121,7 @@ A data item is added to a ring buffer by calling :cpp:func:`sys_ring_buf_put()`.
.. code-block:: c .. code-block:: c
uint32_t my_data[MY_DATA_WORDS]; u32_t my_data[MY_DATA_WORDS];
int ret; int ret;
ret = sys_ring_buf_put(&ring_buf, TYPE_FOO, 0, my_data, SIZE32_OF(my_data)); ret = sys_ring_buf_put(&ring_buf, TYPE_FOO, 0, my_data, SIZE32_OF(my_data));
@ -152,16 +152,16 @@ A data item is removed from a ring buffer by calling
.. code-block:: c .. code-block:: c
uint32_t my_data[MY_DATA_WORDS]; u32_t my_data[MY_DATA_WORDS];
uint16_t my_type; u16_t my_type;
uint8_t my_value; u8_t my_value;
uint8_t my_size; u8_t my_size;
int ret; int ret;
my_size = SIZE32_OF(my_data); my_size = SIZE32_OF(my_data);
ret = sys_ring_buf_get(&ring_buf, &my_type, &my_value, my_data, &my_size); ret = sys_ring_buf_get(&ring_buf, &my_type, &my_value, my_data, &my_size);
if (ret == -EMSGSIZE) { if (ret == -EMSGSIZE) {
printk("Buffer is too small, need %d uint32_t\n", my_size); printk("Buffer is too small, need %d u32_t\n", my_size);
} else if (ret == -EAGAIN) { } else if (ret == -EAGAIN) {
printk("Ring buffer is empty\n"); printk("Ring buffer is empty\n");
} else { } else {

View file

@ -47,12 +47,12 @@ each thread calls a specific routine.
int call_tracking_routine(void) int call_tracking_routine(void)
{ {
uint32_t call_count; u32_t call_count;
if (k_is_in_isr()) { if (k_is_in_isr()) {
/* ignore any call made by an ISR */ /* ignore any call made by an ISR */
} else { } else {
call_count = (uint32_t)k_thread_custom_data_get(); call_count = (u32_t)k_thread_custom_data_get();
call_count++; call_count++;
k_thread_custom_data_set((void *)call_count); k_thread_custom_data_set((void *)call_count);
} }

View file

@ -93,8 +93,8 @@ between two points in time.
.. code-block:: c .. code-block:: c
int64_t time_stamp; s64_t time_stamp;
int64_t milliseconds_spent; s64_t milliseconds_spent;
/* capture initial time stamp */ /* capture initial time stamp */
time_stamp = k_uptime_get(); time_stamp = k_uptime_get();
@ -113,10 +113,10 @@ between two points in time.
.. code-block:: c .. code-block:: c
uint32_t start_time; u32_t start_time;
uint32_t stop_time; u32_t stop_time;
uint32_t cycles_spent; u32_t cycles_spent;
uint32_t nanoseconds_spent; u32_t nanoseconds_spent;
/* capture initial time stamp */ /* capture initial time stamp */
start_time = k_cycle_get_32(); start_time = k_cycle_get_32();

View file

@ -32,7 +32,7 @@ struct nano_sem nanoSemFiber;
void fiberEntry(void) void fiberEntry(void)
{ {
struct nano_timer timer; struct nano_timer timer;
uint32_t data[2] = {0, 0}; u32_t data[2] = {0, 0};
nano_sem_init(&nanoSemFiber); nano_sem_init(&nanoSemFiber);
nano_timer_init(&timer, data); nano_timer_init(&timer, data);
@ -54,7 +54,7 @@ void fiberEntry(void)
void main(void) void main(void)
{ {
struct nano_timer timer; struct nano_timer timer;
uint32_t data[2] = {0, 0}; u32_t data[2] = {0, 0};
task_fiber_start(&fiberStack[0], STACKSIZE, task_fiber_start(&fiberStack[0], STACKSIZE,
(nano_fiber_entry_t) fiberEntry, 0, 0, 7, 0); (nano_fiber_entry_t) fiberEntry, 0, 0, 7, 0);

View file

@ -69,8 +69,8 @@ An **interrupt event** has the following format:
.. code-block:: c .. code-block:: c
struct { struct {
uint32_t timestamp; /* time of interrupt */ u32_t timestamp; /* time of interrupt */
uint32_t interrupt_id; /* ID of interrupt */ u32_t interrupt_id; /* ID of interrupt */
}; };
A **context-switch event** has the following format: A **context-switch event** has the following format:
@ -78,8 +78,8 @@ A **context-switch event** has the following format:
.. code-block:: c .. code-block:: c
struct { struct {
uint32_t timestamp; /* time of context switch */ u32_t timestamp; /* time of context switch */
uint32_t context_id; /* ID of thread that was switched out */ u32_t context_id; /* ID of thread that was switched out */
}; };
A **sleep event** has the following format: A **sleep event** has the following format:
@ -87,9 +87,9 @@ A **sleep event** has the following format:
.. code-block:: c .. code-block:: c
struct { struct {
uint32_t sleep_timestamp; /* time when CPU entered sleep mode */ u32_t sleep_timestamp; /* time when CPU entered sleep mode */
uint32_t wake_timestamp; /* time when CPU exited sleep mode */ u32_t wake_timestamp; /* time when CPU exited sleep mode */
uint32_t interrupt_id; /* ID of interrupt that woke CPU */ u32_t interrupt_id; /* ID of interrupt that woke CPU */
}; };
A **custom event** must have a type ID that does not conflict with A **custom event** must have a type ID that does not conflict with
@ -137,10 +137,10 @@ recorded by the kernel event logger.
.. code-block:: c .. code-block:: c
uint16_t event_id; u16_t event_id;
uint8_t dropped_count; u8_t dropped_count;
uint32_t data[3]; u32_t data[3];
uint8_t data_size; u8_t data_size;
while(1) { while(1) {
/* retrieve an event */ /* retrieve an event */
@ -200,7 +200,7 @@ event consisting of two 32-bit words to the kernel event logger.
/* record custom event only if recording is currently wanted */ /* record custom event only if recording is currently wanted */
if (sys_k_must_log_event(MY_CUSTOM_EVENT_ID)) { if (sys_k_must_log_event(MY_CUSTOM_EVENT_ID)) {
uint32_t data[2]; u32_t data[2];
data[0] = custom_data_1; data[0] = custom_data_1;
data[1] = custom_data_2; data[1] = custom_data_2;

View file

@ -62,9 +62,9 @@ Add
.. code-block:: c .. code-block:: c
void *net_buf_add(struct net_buf *buf, size_t len); void *net_buf_add(struct net_buf *buf, size_t len);
uint8_t *net_buf_add_u8(struct net_buf *buf, uint8_t value); u8_t *net_buf_add_u8(struct net_buf *buf, u8_t value);
void net_buf_add_le16(struct net_buf *buf, uint16_t value); void net_buf_add_le16(struct net_buf *buf, u16_t value);
void net_buf_add_le32(struct net_buf *buf, uint32_t value); void net_buf_add_le32(struct net_buf *buf, u32_t value);
Push Push
Prepend data to the beginning of the buffer. Modifies both the data Prepend data to the beginning of the buffer. Modifies both the data
@ -74,8 +74,8 @@ Push
.. code-block:: c .. code-block:: c
void *net_buf_push(struct net_buf *buf, size_t len); void *net_buf_push(struct net_buf *buf, size_t len);
void net_buf_push_le16(struct net_buf *buf, uint16_t value); void net_buf_push_le16(struct net_buf *buf, u16_t value);
uint32_t net_buf_pull_le32(struct net_buf *buf); u32_t net_buf_pull_le32(struct net_buf *buf);
Pull Pull
Remove data from the beginning of the buffer. Modifies both the data Remove data from the beginning of the buffer. Modifies both the data
@ -85,8 +85,8 @@ Pull
.. code-block:: c .. code-block:: c
void *net_buf_pull(struct net_buf *buf, size_t len); void *net_buf_pull(struct net_buf *buf, size_t len);
uint8_t net_buf_pull_u8(struct net_buf *buf); u8_t net_buf_pull_u8(struct net_buf *buf);
uint16_t net_buf_pull_le16(struct net_buf *buf); u16_t net_buf_pull_le16(struct net_buf *buf);
The Add and Push operations are used when encoding data into the buffer, The Add and Push operations are used when encoding data into the buffer,
whereas Pull is used when decoding data from a buffer. whereas Pull is used when decoding data from a buffer.

View file

@ -73,7 +73,7 @@ You define your handler modelled with this signature:
.. code-block:: c .. code-block:: c
static int your_handler(uint32_t mgmt_event, struct net_if *iface, static int your_handler(u32_t mgmt_event, struct net_if *iface,
void *data, size_t len); void *data, size_t len);
and then register it with an associated mgmt_request code: and then register it with an associated mgmt_request code:

View file

@ -101,7 +101,7 @@ Suspend Hook function
.. code-block:: c .. code-block:: c
int _sys_soc_suspend(int32_t ticks); int _sys_soc_suspend(s32_t ticks);
When the kernel is about to go idle, the power management subsystem calls the When the kernel is about to go idle, the power management subsystem calls the
:code:`_sys_soc_suspend()` function, notifying the SOC interface that the kernel :code:`_sys_soc_suspend()` function, notifying the SOC interface that the kernel
@ -317,7 +317,7 @@ Default Initializer Function
.. code-block:: c .. code-block:: c
int device_pm_control_nop(struct device *unused_device, uint32_t unused_ctrl_command, void *unused_context); int device_pm_control_nop(struct device *unused_device, u32_t unused_ctrl_command, void *unused_context);
If the driver doesn't implement any power control operations, the driver can If the driver doesn't implement any power control operations, the driver can
@ -353,7 +353,7 @@ Device Set Power State
.. code-block:: c .. code-block:: c
int device_set_power_state(struct device *device, uint32_t device_power_state); int device_set_power_state(struct device *device, u32_t device_power_state);
Calls the :c:func:`device_pm_control()` handler function implemented by the Calls the :c:func:`device_pm_control()` handler function implemented by the
device driver with DEVICE_PM_SET_POWER_STATE command. device driver with DEVICE_PM_SET_POWER_STATE command.
@ -363,7 +363,7 @@ Device Get Power State
.. code-block:: c .. code-block:: c
int device_get_power_state(struct device *device, uint32_t * device_power_state); int device_get_power_state(struct device *device, u32_t * device_power_state);
Calls the :c:func:`device_pm_control()` handler function implemented by the Calls the :c:func:`device_pm_control()` handler function implemented by the
device driver with DEVICE_PM_GET_POWER_STATE command. device driver with DEVICE_PM_GET_POWER_STATE command.

View file

@ -21,8 +21,8 @@ Structures
.. code-block:: c .. code-block:: c
struct usb_dc_ep_cfg_data { struct usb_dc_ep_cfg_data {
uint8_t ep_addr; u8_t ep_addr;
uint16_t ep_mps; u16_t ep_mps;
enum usb_dc_ep_type ep_type; enum usb_dc_ep_type ep_type;
}; };
@ -168,7 +168,7 @@ Callback function signature for the device status.
.. code-block:: c .. code-block:: c
typedef void (*usb_ep_callback)(uint8_t ep, typedef void (*usb_ep_callback)(u8_t ep,
enum usb_dc_ep_cb_status_code cb_status); enum usb_dc_ep_cb_status_code cb_status);
Callback function signature for the USB Endpoint. Callback function signature for the USB Endpoint.
@ -176,7 +176,7 @@ Callback function signature for the USB Endpoint.
.. code-block:: c .. code-block:: c
typedef int (*usb_request_handler) (struct usb_setup_packet *setup, typedef int (*usb_request_handler) (struct usb_setup_packet *setup,
int *transfer_len, uint8_t **payload_data); int *transfer_len, u8_t **payload_data);
Callback function signature for class specific requests. For host to device Callback function signature for class specific requests. For host to device
direction the 'len' and 'payload_data' contain the length of the received data direction the 'len' and 'payload_data' contain the length of the received data
@ -189,7 +189,7 @@ respectively.
struct usb_ep_cfg_data { struct usb_ep_cfg_data {
usb_ep_callback ep_cb; usb_ep_callback ep_cb;
uint8_t ep_addr; u8_t ep_addr;
}; };
This structure contains configuration for a certain endpoint. This structure contains configuration for a certain endpoint.
@ -204,7 +204,7 @@ This structure contains configuration for a certain endpoint.
struct usb_interface_cfg_data { struct usb_interface_cfg_data {
usb_request_handler class_handler; usb_request_handler class_handler;
usb_request_handler custom_handler; usb_request_handler custom_handler;
uint8_t *payload_data; u8_t *payload_data;
}; };
This structure contains USB interface configuration. This structure contains USB interface configuration.
@ -220,10 +220,10 @@ This structure contains USB interface configuration.
.. code-block:: c .. code-block:: c
struct usb_cfg_data { struct usb_cfg_data {
const uint8_t *usb_device_description; const u8_t *usb_device_description;
usb_status_callback cb_usb_status; usb_status_callback cb_usb_status;
struct usb_interface_cfg_data interface; struct usb_interface_cfg_data interface;
uint8_t num_endpoints; u8_t num_endpoints;
struct usb_ep_cfg_data *endpoint; struct usb_ep_cfg_data *endpoint;
}; };
@ -279,7 +279,7 @@ For example, for CDC_ACM sample application:
.. code-block:: c .. code-block:: c
static const uint8_t cdc_acm_usb_description[] = { static const u8_t cdc_acm_usb_description[] = {
/* Device descriptor */ /* Device descriptor */
USB_DEVICE_DESC_SIZE, /* Descriptor size */ USB_DEVICE_DESC_SIZE, /* Descriptor size */
USB_DEVICE_DESC, /* Descriptor type */ USB_DEVICE_DESC, /* Descriptor type */
@ -472,7 +472,7 @@ class requests:
.. code-block:: c .. code-block:: c
int cdc_acm_class_handle_req(struct usb_setup_packet *pSetup, int cdc_acm_class_handle_req(struct usb_setup_packet *pSetup,
int32_t *len, uint8_t **data) s32_t *len, u8_t **data)
{ {
struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(cdc_acm_dev); struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(cdc_acm_dev);
@ -487,12 +487,12 @@ class requests:
break; break;
case CDC_SET_CONTROL_LINE_STATE: case CDC_SET_CONTROL_LINE_STATE:
dev_data->line_state = (uint8_t)sys_le16_to_cpu(pSetup->wValue); dev_data->line_state = (u8_t)sys_le16_to_cpu(pSetup->wValue);
DBG("CDC_SET_CONTROL_LINE_STATE 0x%x\n", dev_data->line_state); DBG("CDC_SET_CONTROL_LINE_STATE 0x%x\n", dev_data->line_state);
break; break;
case CDC_GET_LINE_CODING: case CDC_GET_LINE_CODING:
*data = (uint8_t *)(&dev_data->line_coding); *data = (u8_t *)(&dev_data->line_coding);
*len = sizeof(dev_data->line_coding); *len = sizeof(dev_data->line_coding);
DBG("\nCDC_GET_LINE_CODING %d %d %d %d\n", DBG("\nCDC_GET_LINE_CODING %d %d %d %d\n",
sys_le32_to_cpu(dev_data->line_coding.dwDTERate), sys_le32_to_cpu(dev_data->line_coding.dwDTERate),