board.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef BOARD_H
23 #define BOARD_H
24 
25 #include <stdint.h>
26 
27 /* RIOT includes */
28 #include <motor_driver.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
38 void _native_LED_GREEN_OFF(void);
39 void _native_LED_GREEN_ON(void);
40 void _native_LED_GREEN_TOGGLE(void);
41 void _native_LED_RED_OFF(void);
42 void _native_LED_RED_ON(void);
43 void _native_LED_RED_TOGGLE(void);
44 
45 #define LED0_ON (_native_LED_RED_ON())
46 #define LED0_OFF (_native_LED_RED_OFF())
47 #define LED0_TOGGLE (_native_LED_RED_TOGGLE())
48 #define LED1_ON (_native_LED_GREEN_ON())
49 #define LED1_OFF (_native_LED_GREEN_OFF())
50 #define LED1_TOGGLE (_native_LED_GREEN_TOGGLE())
53 #if defined(MODULE_MTD) || DOXYGEN
58 #ifndef MTD_PAGE_SIZE
59 #if defined(MODULE_FATFS) || defined(MODULE_LWEXT4)
60 #define MTD_PAGE_SIZE (512)
61 #else
62 #define MTD_PAGE_SIZE (256)
63 #endif
64 #endif
65 #ifndef MTD_SECTOR_SIZE
66 #if defined(MODULE_FATFS) || defined(MODULE_LWEXT4)
67 #define MTD_SECTOR_SIZE (512)
68 #else
69 #define MTD_SECTOR_SIZE (4096)
70 #endif
71 #endif
72 #ifndef MTD_SECTOR_NUM
73 #if defined(MODULE_FATFS) || defined(MODULE_LWEXT4)
74 #define MTD_SECTOR_NUM (32768)
75 #else
76 #define MTD_SECTOR_NUM (2048)
77 #endif
78 #endif
81 #ifndef MTD_WRITE_SIZE
82 #define MTD_WRITE_SIZE (1)
83 #endif
84 #ifndef MTD_NATIVE_FILENAME
85 #define MTD_NATIVE_FILENAME "MEMORY.bin"
86 #endif
90 #define MTD_0 mtd_dev_get(0)
91 #endif
92 
97 #ifndef FS_NATIVE_DIR
98 #define FS_NATIVE_DIR "native"
99 #endif
102 #if defined(MODULE_SPIFFS) || DOXYGEN
107 /* SPIFFS config flags */
108 #ifndef SPIFFS_READ_ONLY
109 #define SPIFFS_READ_ONLY (0)
110 #endif
111 #ifndef SPIFFS_SINGLETON
112 #define SPIFFS_SINGLETON (0)
113 #endif
114 #ifndef SPIFFS_HAL_CALLBACK_EXTRA
115 #define SPIFFS_HAL_CALLBACK_EXTRA (1)
116 #endif
117 #ifndef SPIFFS_CACHE
118 #define SPIFFS_CACHE (1)
119 #endif
120 
121 #if SPIFFS_SINGLETON == 1
122 /* MTD config if singleton is used */
123 #ifndef SPIFFS_CFG_PHYS_SZ
124 #define SPIFFS_CFG_PHYS_SZ(ignore) (MTD_SECTOR_SIZE * MTD_SECTOR_NUM)
125 #endif
126 #ifndef SPIFFS_CFG_PHYS_ERASE_SZ
127 #define SPIFFS_CFG_PHYS_ERASE_SZ(ignore) (MTD_SECTOR_SIZE)
128 #endif
129 #ifndef SPIFFS_CFG_PHYS_ADDR
130 #define SPIFFS_CFG_PHYS_ADDR(ignore) (0)
131 #endif
132 #ifndef SPIFFS_CFG_LOG_PAGE_SZ
133 #define SPIFFS_CFG_LOG_PAGE_SZ(ignore) (MTD_PAGE_SIZE)
134 #endif
135 #ifndef SPIFFS_CFG_LOG_BLOCK_SZ
136 #define SPIFFS_CFG_LOG_BLOCK_SZ(ignore) (MTD_SECTOR_SIZE)
137 #endif
138 #endif
139 
140 #if SPIFFS_HAL_CALLBACK_EXTRA == 0
141 /* Default MTD device if no callback parameter */
142 #ifndef SPIFFS_MTD_DEV
143 #define SPIFFS_MTD_DEV (MTD_0)
144 #endif
145 #endif
147 #endif
148 
149 #if MODULE_PERIPH_QDEC
159 void native_motor_driver_qdec_simulation( \
160  const motor_driver_t motor_driver, uint8_t motor_id, \
161  int32_t pwm_duty_cycle);
162 
163 /* C++ standard do not support designated initializers */
164 #if !(defined __cplusplus) && (defined MODULE_PERIPH_QDEC)
165 
170 static const motor_driver_config_t motor_driver_config[] = {
171  {
172  .pwm_dev = 0,
173  .mode = MOTOR_DRIVER_1_DIR_BRAKE,
174  .mode_brake = MOTOR_BRAKE_LOW,
175  .pwm_mode = PWM_LEFT,
176  .pwm_frequency = 20000U,
177  .pwm_resolution = 1000U,
178  .nb_motors = 2,
179  .motors = {
180  {
181  .pwm_channel = 0,
182  .gpio_enable = GPIO_PIN(0, 0),
183  .gpio_dir0 = GPIO_PIN(0, 0),
184  .gpio_dir1_or_brake = GPIO_PIN(0, 0),
185  .gpio_dir_reverse = 0,
186  .gpio_enable_invert = 0,
187  .gpio_brake_invert = 0,
188  },
189  {
190  .pwm_channel = 1,
191  .gpio_enable = GPIO_PIN(0, 0),
192  .gpio_dir0 = GPIO_PIN(0, 0),
193  .gpio_dir1_or_brake = GPIO_PIN(0, 0),
194  .gpio_dir_reverse = 1,
195  .gpio_enable_invert = 0,
196  .gpio_brake_invert = 0,
197  },
198  },
199  .cb = native_motor_driver_qdec_simulation,
200  },
201 };
202 
203 #define MOTOR_DRIVER_NUMOF ARRAY_SIZE(motor_driver_config)
205 #endif
206 
211 #define CONFIG_ZTIMER_USEC_TYPE ZTIMER_TYPE_PERIPH_TIMER
212 #define CONFIG_ZTIMER_USEC_DEV TIMER_DEV(0)
213 /* on native, anything can happen... */
214 #define CONFIG_ZTIMER_USEC_MIN (64)
217 #endif /* __cplusplus */
218 
219 #ifdef __cplusplus
220 }
221 #endif
222 
224 #endif /* BOARD_H */
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:46
unsigned int motor_driver_t
Default motor driver type definition.
Definition: motor_driver.h:156
@ MOTOR_DRIVER_1_DIR_BRAKE
Single GPIO for direction, \ Single GPIO for BRAKE.
Definition: motor_driver.h:120
@ MOTOR_BRAKE_LOW
Low stage brake.
Definition: motor_driver.h:128
@ PWM_LEFT
left aligned
Definition: periph_conf.h:221
High-level driver for DC motors.
Describe DC motor driver with PWM device and motors array.
Definition: motor_driver.h:168
pwm_t pwm_dev
PWM device driving motors.
Definition: motor_driver.h:169