/ src / piolib / include / pio_platform.h
pio_platform.h
 1  // SPDX-License-Identifier: GPL-2.0
 2  /*
 3   * Copyright (c) 2024 Raspberry Pi Ltd.
 4   * All rights reserved.
 5   */
 6  
 7  #ifndef _PIO_PLATFORM_H
 8  #define _PIO_PLATFORM_H
 9  
10  #include <assert.h>
11  #include <inttypes.h>
12  #include <stdbool.h>
13  
14  #ifndef __unused
15  #define __unused __attribute__((unused))
16  #endif
17  
18  #define PICO_DEFAULT_LED_PIN 4
19  
20  #ifndef PARAM_ASSERTIONS_ENABLE_ALL
21  #define PARAM_ASSERTIONS_ENABLE_ALL 0
22  #endif
23  
24  #ifndef PARAM_ASSERTIONS_DISABLE_ALL
25  #define PARAM_ASSERTIONS_DISABLE_ALL 0
26  #endif
27  
28  #define PARAM_ASSERTIONS_ENABLED(x)                                            \
29      ((PARAM_ASSERTIONS_ENABLED_##x || PARAM_ASSERTIONS_ENABLE_ALL) &&          \
30       !PARAM_ASSERTIONS_DISABLE_ALL)
31  #define invalid_params_if(x, test)                                             \
32      ({                                                                         \
33          if (PARAM_ASSERTIONS_ENABLED(x))                                       \
34              assert(!(test));                                                   \
35      })
36  #define valid_params_if(x, test)                                               \
37      ({                                                                         \
38          if (PARAM_ASSERTIONS_ENABLED(x))                                       \
39              assert(test);                                                      \
40      })
41  
42  #define STATIC_ASSERT(cond) static_assert(cond, #cond)
43  
44  #define _u(x) ((uint)(x))
45  #define bool_to_bit(x) ((uint) !!(x))
46  
47  #ifndef count_of
48  #define count_of(a) (sizeof(a) / sizeof((a)[0]))
49  #endif
50  
51  typedef unsigned int uint;
52  
53  #endif