Skip to content

HAL configuration #518

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

Merged
merged 15 commits into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cores/arduino/Tone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "Arduino.h"

PinName g_lastPin = NC;

#ifdef HAL_TIM_MODULE_ENABLED
static stimer_t _timer;

// frequency (in hertz) and duration (in milliseconds).
Expand All @@ -47,3 +49,16 @@ void noTone(uint8_t _pin)
g_lastPin = NC;
}
}
#else
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
{
UNUSED(_pin);
UNUSED(frequency);
UNUSED(duration);
}

void noTone(uint8_t _pin)
{
UNUSED(_pin);
}
#endif /* HAL_TIM_MODULE_ENABLED */
17 changes: 17 additions & 0 deletions cores/arduino/WInterrupts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

void attachInterrupt(uint32_t pin, callback_function_t callback, uint32_t mode)
{
#if !defined(HAL_EXTI_MODULE_DISABLED)
uint32_t it_mode;
PinName p = digitalPinToPinName(pin);
GPIO_TypeDef *port = set_GPIO_Port_Clock(STM_PORT(p));
Expand Down Expand Up @@ -53,20 +54,36 @@ void attachInterrupt(uint32_t pin, callback_function_t callback, uint32_t mode)
#endif /* STM32F1xx */

stm32_interrupt_enable(port, STM_GPIO_PIN(p), callback, it_mode);
#else
UNUSED(pin);
UNUSED(callback);
UNUSED(mode);
#endif
}

void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode)
{
#if !defined(HAL_EXTI_MODULE_DISABLED)
callback_function_t _c = callback;
attachInterrupt(pin, _c, mode);
#else
UNUSED(pin);
UNUSED(callback);
UNUSED(mode);
#endif

}

void detachInterrupt(uint32_t pin)
{
#if !defined(HAL_EXTI_MODULE_DISABLED)
PinName p = digitalPinToPinName(pin);
GPIO_TypeDef *port = get_GPIO_Port(STM_PORT(p));
if (!port) {
return;
}
stm32_interrupt_disable(port, STM_GPIO_PIN(p));
#else
UNUSED(pin);
#endif
}
4 changes: 4 additions & 0 deletions cores/arduino/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
*/
#ifndef _PINS_ARDUINO_H_
#define _PINS_ARDUINO_H_
#include <stdlib.h> /* Required for static_assert */
// Include board variant
#include "variant.h"
#include "PinNames.h"


// Avoid PortName issue
_Static_assert(LastPort <= 0x0F, "PortName must be less than 16");
Expand Down Expand Up @@ -201,6 +204,7 @@ static const uint8_t SCL = PIN_WIRE_SCL;
#ifdef __cplusplus
extern "C" {
#endif
extern const PinName digitalPin[];

#define NOT_AN_INTERRUPT NC // -1

Expand Down
20 changes: 16 additions & 4 deletions cores/arduino/stm32/analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@
extern "C" {
#endif


/* Private_Variables */
#if defined(HAL_ADC_MODULE_ENABLED) || defined(HAL_DAC_MODULE_ENABLED) ||\
defined(HAL_TIM_MODULE_ENABLED)
static PinName g_current_pin = NC;
#endif

/* Private_Defines */
#ifdef HAL_ADC_MODULE_ENABLED

#if defined(ADC_SAMPLETIME_8CYCLES_5)
#define SAMPLINGTIME ADC_SAMPLETIME_8CYCLES_5;
#elif defined(ADC_SAMPLETIME_12CYCLES_5)
Expand Down Expand Up @@ -79,9 +88,6 @@ extern "C" {
#define ADC_REGULAR_RANK_1 1
#endif

/* Private_Variables */
static PinName g_current_pin = NC;

/* Private Functions */
static uint32_t get_adc_channel(PinName pin)
{
Expand Down Expand Up @@ -155,7 +161,9 @@ static uint32_t get_adc_channel(PinName pin)
}
return channel;
}
#endif /* HAL_ADC_MODULE_ENABLED */

#ifdef HAL_TIM_MODULE_ENABLED
static uint32_t get_pwm_channel(PinName pin)
{
uint32_t function = pinmap_function(pin, PinMap_PWM);
Expand All @@ -179,6 +187,7 @@ static uint32_t get_pwm_channel(PinName pin)
}
return channel;
}
#endif /* HAL_TIM_MODULE_ENABLED */

#ifdef HAL_DAC_MODULE_ENABLED
static uint32_t get_dac_channel(PinName pin)
Expand Down Expand Up @@ -337,7 +346,7 @@ void dac_stop(PinName pin)
}
#endif //HAL_DAC_MODULE_ENABLED


#ifdef HAL_ADC_MODULE_ENABLED
////////////////////////// ADC INTERFACE FUNCTIONS /////////////////////////////

/**
Expand Down Expand Up @@ -641,7 +650,9 @@ uint16_t adc_read_value(PinName pin)

return uhADCxConvertedValue;
}
#endif /* HAL_ADC_MODULE_ENABLED */

#ifdef HAL_TIM_MODULE_ENABLED
////////////////////////// PWM INTERFACE FUNCTIONS /////////////////////////////


Expand Down Expand Up @@ -775,6 +786,7 @@ void pwm_stop(PinName pin)

HAL_TIM_PWM_DeInit(&timHandle);
}
#endif /* HAL_TIM_MODULE_ENABLED */

#ifdef __cplusplus
}
Expand Down
3 changes: 3 additions & 0 deletions cores/arduino/stm32/interrupt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
*/
#include "interrupt.h"

#if !defined(HAL_EXTI_MODULE_DISABLED)

/* Private Types */

/*As we can have only one interrupt/pin id, don't need to get the port info*/
Expand Down Expand Up @@ -370,5 +372,6 @@ void EXTI15_10_IRQHandler(void)
#ifdef __cplusplus
}
#endif
#endif /* !HAL_EXTI_MODULE_DISABLED */
#endif
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
5 changes: 4 additions & 1 deletion cores/arduino/stm32/interrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
#define __INTERRUPT_H

/* Includes ------------------------------------------------------------------*/
#include "variant.h"
#include "stm32_def.h"

#if !defined(HAL_EXTI_MODULE_DISABLED)

#if defined(STM32F3xx)
#define EXTI2_IRQn EXTI2_TSC_IRQn
Expand All @@ -67,6 +69,7 @@ void stm32_interrupt_enable(GPIO_TypeDef *port, uint16_t pin, callback_function_
/* Exported functions ------------------------------------------------------- */
void stm32_interrupt_enable(GPIO_TypeDef *port, uint16_t pin, void (*callback)(void), uint32_t mode);
void stm32_interrupt_disable(GPIO_TypeDef *port, uint16_t pin);
#endif /* !HAL_EXTI_MODULE_DISABLED */

#endif /* __INTERRUPT_H */

Expand Down
3 changes: 2 additions & 1 deletion cores/arduino/stm32/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
#define __RTC_H

/* Includes ------------------------------------------------------------------*/
#include "variant.h"
#include <stdbool.h>
#include "stm32_def.h"
#include "backup.h"
#include "clock.h"

Expand Down
2 changes: 2 additions & 0 deletions cores/arduino/stm32/spi_com.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#if defined(HAL_SPI_MODULE_ENABLED)

/* Private Functions */
/**
Expand Down Expand Up @@ -402,6 +403,7 @@ spi_status_e spi_transfer(spi_t *obj, uint8_t *tx_buffer,

return ret;
}
#endif /* HAL_SPI_MODULE_ENABLED */

#ifdef __cplusplus
}
Expand Down
2 changes: 2 additions & 0 deletions cores/arduino/stm32/spi_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#if defined(HAL_SPI_MODULE_ENABLED)

/* Exported types ------------------------------------------------------------*/

Expand Down Expand Up @@ -101,6 +102,7 @@ spi_status_e spi_send(spi_t *obj, uint8_t *Data, uint16_t len, uint32_t Timeout)
spi_status_e spi_transfer(spi_t *obj, uint8_t *tx_buffer,
uint8_t *rx_buffer, uint16_t len, uint32_t Timeout);
uint32_t spi_getClkFreq(spi_t *obj);
#endif /* HAL_SPI_MODULE_ENABLED */

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion cores/arduino/stm32/stm32_eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define __STM32_EEPROM_H

/* Includes ------------------------------------------------------------------*/
#include "variant.h"
#include "stm32_def.h"

#ifdef __cplusplus
extern "C" {
Expand Down
150 changes: 150 additions & 0 deletions cores/arduino/stm32/stm32yyxx_hal_conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#ifndef __STM32YYxx_HAL_CONF_H
#define __STM32YYxx_HAL_CONF_H

/*
* Mandatory HAL modules
*/
#define HAL_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED /* Required by other modules */
#define HAL_FLASH_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED

/*
* Optional HAL modules, can be enabled/disabled using
* variant.h, build_opt.h or hal_conf_extra.h
*/
/*
* Defined by default
*/
#if !defined(HAL_ADC_MODULE_DISABLED)
#define HAL_ADC_MODULE_ENABLED
#else
#undef HAL_ADC_MODULE_ENABLED
#endif

#if !defined(HAL_I2C_MODULE_DISABLED)
#define HAL_I2C_MODULE_ENABLED
#else
#undef HAL_I2C_MODULE_ENABLED
#endif

#if !defined(HAL_RTC_MODULE_DISABLED)
#define HAL_RTC_MODULE_ENABLED
#else
#undef HAL_RTC_MODULE_ENABLED
#endif

#if !defined(HAL_SPI_MODULE_DISABLED)
#define HAL_SPI_MODULE_ENABLED
#else
#undef HAL_SPI_MODULE_ENABLED
#endif

#if !defined(HAL_TIM_MODULE_DISABLED)
#define HAL_TIM_MODULE_ENABLED
#else
#undef HAL_TIM_MODULE_ENABLED
#endif

/*
* Not defined by default
*/
#if !defined(HAL_DAC_MODULE_DISABLED)
/*#define HAL_DAC_MODULE_ENABLED*/
#else
#undef HAL_DAC_MODULE_ENABLED
#endif

/* Note: interrupt API does not used HAL EXTI module */
/* anyway API is cleaned with HAL_EXTI_MODULE_DISABLED */
#if !defined(HAL_EXTI_MODULE_DISABLED)
/*#define HAL_EXTI_MODULE_ENABLED*/
#else
#undef HAL_EXTI_MODULE_ENABLED
#endif

#if !defined(HAL_ETH_MODULE_DISABLED)
/*#define HAL_ETH_MODULE_ENABLED*/
#else
#undef HAL_ETH_MODULE_ENABLED
#endif

#if !defined(HAL_SD_MODULE_DISABLED)
/*#define HAL_SD_MODULE_ENABLED*/
#else
#undef HAL_SD_MODULE_ENABLED
#endif

#if !defined(HAL_QSPI_MODULE_DISABLED)
/*#define HAL_QSPI_MODULE_ENABLED*/
#else
#undef HAL_QSPI_MODULE_ENABLED
#endif

/*
* Disabled HAL modules, handled thanks Arduino menu
*/
/*#define HAL_UART_MODULE_ENABLED*/
/*#define HAL_PCD_MODULE_ENABLED*/

/*
* Unused HAL modules
*/
#if 0
HAL_CAN_LEGACY_MODULE_ENABLED
HAL_CAN_LEGACY_MODULE_ENABLED
HAL_CEC_MODULE_ENABLED
HAL_COMP_MODULE_ENABLED
HAL_CRC_MODULE_ENABLED
HAL_CRYP_MODULE_ENABLED
HAL_DCMI_MODULE_ENABLED
HAL_DFSDM_MODULE_ENABLED
HAL_DMA2D_MODULE_ENABLED
HAL_DSI_MODULE_ENABLED
HAL_EXTI_MODULE_ENABLED // interrupt API does not use the module
HAL_FDCAN_MODULE_ENABLED
HAL_FIREWALL_MODULE_ENABLED
HAL_FMPI2C_MODULE_ENABLED
HAL_GFXMMU_MODULE_ENABLED
HAL_HASH_MODULE_ENABLED
HAL_HCD_MODULE_ENABLED
HAL_HRTIM_MODULE_ENABLED
HAL_HSEM_MODULE_ENABLED
HAL_I2S_MODULE_ENABLED
HAL_IPCC_MODULE_ENABLED
HAL_IRDA_MODULE_ENABLED
HAL_IWDG_MODULE_ENABLED // IWD built-in library uses LL
HAL_JPEG_MODULE_ENABLED
HAL_LCD_MODULE_ENABLED
HAL_LPTIM_MODULE_ENABLED
HAL_LTDC_MODULE_ENABLED
HAL_MDIOS_MODULE_ENABLED
HAL_MDMA_MODULE_ENABLED
HAL_MMC_MODULE_ENABLED
HAL_NAND_MODULE_ENABLED
HAL_NOR_MODULE_ENABLED
HAL_OPAMP_MODULE_ENABLED
HAL_OSPI_MODULE_ENABLED
HAL_PCCARD_MODULE_ENABLED
HAL_PKA_MODULE_ENABLED
HAL_RAMECC_MODULE_ENABLED
HAL_RNG_MODULE_ENABLED
HAL_SAI_MODULE_ENABLED
HAL_SDADC_MODULE_ENABLED
HAL_SDRAM_MODULE_ENABLED
HAL_SMARTCARD_MODULE_ENABLED
HAL_SMBUS_MODULE_ENABLED
HAL_SPDIFRX_MODULE_ENABLED
HAL_SRAM_MODULE_ENABLED
HAL_SWPMI_MODULE_ENABLED
HAL_TSC_MODULE_ENABLED
HAL_USART_MODULE_ENABLED
HAL_WWDG_MODULE_ENABLED
#endif

#endif /* __STM32YYxx_HAL_CONF_H */


Loading