Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stm32f7nucleo: Add ADC support #1894

Merged

Conversation

rzr
Copy link
Contributor

@rzr rzr commented Jun 20, 2019

Aligned to configuration of NuttX: GPIO_ADC1_IN3
nuttx/configs/nucleo-144/src/stm32_adc.c
(nuttx-7.21-298-gc67b807f43)

More pins/channels may be configured later.

Change-Id: I5407e6b9b91eaa8570713d0331f786441ce0c649
Relate-to: rzr/webthing-iotjs#3
Forwarded: https://github.com/pando-project/iotjs/pull/
IoT.js-DCO-1.0-Signed-off-by: Philippe Coval p.coval@samsung.com

@rzr rzr force-pushed the sandbox/rzr/review/master branch from dd7040b to 5427be8 Compare June 20, 2019 07:28
rzr added a commit to TizenTeam/iotjs that referenced this pull request Jun 20, 2019
Aligned to configuration of NuttX: GPIO_ADC1_IN3
nuttx/configs/nucleo-144/src/stm32_adc.c
(nuttx-7.21-298-gc67b807f43)

More pins/channels may be configured later.

Change-Id: I5407e6b9b91eaa8570713d0331f786441ce0c649
Relate-to: rzr/webthing-iotjs#3
Forwarded: jerryscript-project#1894
IoT.js-DCO-1.0-Signed-off-by: Philippe Coval p.coval@samsung.com

// ADC pin name is "ADC.(number)_(timer)".
#define SET_ADC_CONSTANT(number, timer) \
number_bit = (GPIO_ADC##number##_IN##timer); \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should wrap the macro contents into a do { } while (0); block. Something like this:

#define SET_ADC_CONSTANT(number, timer)        \
   do {                \
   unsigned int number_bit = (GPIO_ADC##number##_IN##timer);  \
   ....   \
   } while (0);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? because this macro is used by the other one

Code is aligned to STM32 discovery, but I can try to improve both later

return stm32_adcinitialize(number, channel_list, 1);
#elif defined(TARGET_BOARD_STM32F7NUCLEO)
return stm32_adc_initialize(number, channel_list, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly this function name comes from nuttx, am I correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but it has a different naming for STM32F7, Maybe I will also try to align in nuttx codebase too but AFAIK each port is free to define its own functions.

static void iotjs_pin_initialize_adc(jerry_value_t jobj) {
unsigned int number_bit;

// ADC pin name is "ADC.(number)_(timer)".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment ok? Based on the property set below, the name is ADC<number>_<timer>, there is no . in the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I will fix this in discovery file too

Copy link
Contributor

@LaszloLango LaszloLango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rzr rzr force-pushed the sandbox/rzr/review/master branch from 5427be8 to 060e841 Compare June 20, 2019 13:26
rzr added a commit to TizenTeam/iotjs that referenced this pull request Jun 20, 2019
Aligned to configuration of NuttX: GPIO_ADC1_IN3
nuttx/configs/nucleo-144/src/stm32_adc.c
(nuttx-7.21-298-gc67b807f43)

More pins/channels may be configured later.

Change-Id: I5407e6b9b91eaa8570713d0331f786441ce0c649
Relate-to: rzr/webthing-iotjs#3
Forwarded: jerryscript-project#1894
IoT.js-DCO-1.0-Signed-off-by: Philippe Coval p.coval@samsung.com
Aligned to configuration of NuttX: GPIO_ADC1_IN3
nuttx/configs/nucleo-144/src/stm32_adc.c
(nuttx-7.21-298-gc67b807f43)

More pins/channels may be configured later.

Also handle difference per processors
(this could be aligned in NuttX codebase).

Change-Id: I5407e6b9b91eaa8570713d0331f786441ce0c649
Relate-to: rzr/webthing-iotjs#3
Forwarded: jerryscript-project#1894
IoT.js-DCO-1.0-Signed-off-by: Philippe Coval p.coval@samsung.com
@rzr rzr force-pushed the sandbox/rzr/review/master branch from 060e841 to f3679c9 Compare June 20, 2019 14:15
Copy link
Contributor

@hs0225 hs0225 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hs0225 hs0225 merged commit a5957f8 into jerryscript-project:master Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants