1 /* Copyright 2016-present Samsung Electronics Co., Ltd. and other contributors
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #if defined(__NUTTX__) && TARGET_BOARD == STM32F4DIS
19 #include "iotjs_systemio-arm-nuttx.h"
20 #include "stm32_gpio.h"
23 void iotjs_gpio_unconfig_nuttx(int pin) {
24 stm32_unconfiggpio(pin);
30 #include "stm32_adc.h"
32 struct adc_dev_s* iotjs_adc_config_nuttx(int number, int timer, int pin) {
33 stm32_configgpio(pin);
35 uint8_t channel_list[1] = { timer };
36 return stm32_adcinitialize(number, channel_list, 1);
39 #endif /* ENABLE_MODULE_ADC */
44 #include "stm32_i2c.h"
46 struct i2c_master_s* iotjs_i2c_config_nuttx(int port) {
47 return stm32_i2cbus_initialize(port);
51 int iotjs_i2c_unconfig_nuttx(struct i2c_master_s* i2c) {
52 return stm32_i2cbus_uninitialize(i2c);
55 #endif /* ENABLE_MODULE_I2C */
60 #include "stm32_pwm.h"
62 struct pwm_lowerhalf_s* iotjs_pwm_config_nuttx(int timer, int pin) {
63 // Set alternative function
64 stm32_configgpio(pin);
67 return stm32_pwminitialize(timer);
70 #endif /* ENABLE_MODULE_PWM */