Add STM32L Discovery board project as a starting point to adapt to an RTOS demo.

This commit is contained in:
Richard Barry 2013-11-20 13:33:30 +00:00
parent 417c3d1054
commit b89fd7c1e3
139 changed files with 71905 additions and 0 deletions

View file

@ -0,0 +1,126 @@
/**
******************************************************************************
* @file discover_functions.h
* @author Microcontroller Division
* @version V1.0.3
* @date May-2013
* @brief This file contains measurement values and board
******************************************************************************
* @copy
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __DISCOVER_FUNCTIONS_H
#define __DISCOVER_FUNCTIONS_H
/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx.h"
#define DELAY Delay(150)
#define TEMPO if(!KeyPressed) DELAY
//#define SLIDER_DETECTED (sMCKeyInfo[0].Setting.b.DETECTED)
//#define SLIDER_POSITION (sMCKeyInfo[0].UnScaledPosition)
#define enableGlobalInterrupts() __set_PRIMASK(0);
#define disableGlobalInterrupts() __set_PRIMASK(1);
#define STR_VERSION tab[1] = 'V';tab[2] = '2'|DOT; tab[3] = '0'|DOT; tab[4] = '4'
#define STATE_VREF 0
#define STATE_SLIDER_VALUE 1
#define STATE_SLIDER_BUTTON 2
#define STATE_ICC_RUN 3
#define STATE_ICC_LP_RUN 4
#define STATE_ICC_STOP 5
#define STATE_ICC_STBY 6
#define MAX_STATE 7
/* Theorically BandGAP 1.224volt */
#define VREF 1.224L
/*
ADC Converter
LSBIdeal = VREF/4096 or VDA/4096
*/
#define ADC_CONV 4096
/*
VDD Factory for VREFINT measurement
*/
#define VDD_FACTORY 3.0L
#define MAX_CURRENT 99999
/* AUTO TEST VALUE */
#define VCC_MIN 2920 /* nominal Vcc/Vdd is 2.99V, allow 2.5% lower - Vref can be ~2% lower than 1.225 */
#define VCC_MAX 3100
#define ICC_RUN_MIN 6000
#define ICC_RUN_MAX 11000 /* typical ICC_RUN is ~0.9mA */
#define ICC_STOP_MIN 250
#define ICC_STOP_MAX 800 /* typical ICC_STOP is 0.6uA */
#define ICC_BIAS_MAX 30 /* ! converter value in decimal ! --> 3.0volts/4036* 30 = 21 mV */
#define ICC_STBY_MIN 150 /* typical ICC_STAND BY is 0.3 uA */
#define ICC_STBY_MAX 450
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
#define AUTOTEST(a) DATA_EEPROM_Unlock(); DATA_EEPROM_FastProgramByte((uint32_t)&self_test,a ) ; DATA_EEPROM_Lock()
/* Exported functions ------------------------------------------------------- */
void Init_Port (void);
void convert_into_char(uint32_t number, uint16_t *p_tab);
void LPR_init(void);
void Halt_Init(void);
uint16_t Vref_measure(void);
void Icc_measure(void);
float Icc_RUN(void);
float Icc_SLEEP(void);
float Icc_LPRUN(void);
float Icc_LPSLEEP(void);
float Icc_STOP(void);
float Icc_Stop_NoRTC(void);
void Icc_STBY(void);
float Icc_STBY_NoRTC(void);
void auto_test(void);
void Bias_measurement(void);
void test_vdd(void);
void test_icc_Run(void);
void test_icc_STOP(void);
void test_icc_STBY(void);
void display_MuAmp (uint32_t);
void FLASH_ProgramBias(uint8_t) ;
float Vdd_appli(void);
uint16_t wake_up_measurement (void);
void RCC_Configuration(void);
void Init_clocks(void);
void Init_GPIOs (void);
void TimingDelay_Decrement(void);
void Delay(uint32_t nTime);
void ExtraCode_StateMachine(void);
void Config_Systick(void);
void Config_Systick_50ms(void);
void Button_value(void);
void Slider_value(void);
void auto_test_part2(void);
#endif /* __DISCOVER_FUNCTIONS_H*/
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,57 @@
/**
******************************************************************************
* @file icc_measure.h
* @author Microcontroller Division
* @version V1.0.3
* @date May-2013
* @brief Current measurements defines
******************************************************************************
* @copy
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ICC_MEASURE_H
#define __ICC_MEASURE_H
/* Includes ------------------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define MCU_RUN 0
#define MCU_SLEEP 1
#define MCU_LP_RUN 2
#define MCU_LP_SLEEP 3
#define MCU_STOP_RTC 4
#define MCU_STOP_NoRTC 5
#define MCU_STBY 6
#define NoRTC FALSE
#define WITHRTC !NoRTC
#define NoDIV2 FALSE
#define DIV2 !NoDIV2
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
uint16_t ADC_Supply(void);
void ADC_Icc_Init(void);
uint16_t ADC_Icc_Test(uint8_t Mcu_State);
void GPIO_LowPower_Config(void);
void STOP_Init(void);
void STBY_Init(void);
uint16_t Current_Measurement(void);
void EnterLPSLEEPModeRAM(void);
void SetHSICLKToMSI(uint32_t ,bool ,bool );
void EnterLPRUNModeRAM(void);
#endif /* __ICC_MEASURE_H*/
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,52 @@
/**
******************************************************************************
* @file Project/STM32L1xx_StdPeriph_Template/main.h
* @author MCD Application Team
* @version V1.0.3
* @date May-2013
* @brief Header for main.c module
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H
/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx.h"
#include "discover_board.h"
#include "stm32l_discovery_lcd.h"
#include <stdio.h>
/* Touch sensing driver headers */
#include "tsl.h"
#include "tsl_user.h"
/* discovery board and specific drivers headers*/
#include "discover_board.h"
#include "icc_measure.h"
#include "discover_functions.h"
#include "stm32l_discovery_lcd.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void Delay(__IO uint32_t nTime);
#endif /* __MAIN_H */
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,75 @@
/**
******************************************************************************
* @file Project/STM32L1xx_StdPeriph_Template/stm32l1xx_conf.h
* @author MCD Application Team
* @version V1.0.3
* @date May-2013
* @brief Library configuration file.
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L1xx_CONF_H
#define __STM32L1xx_CONF_H
/* Includes ------------------------------------------------------------------*/
/* Comment the line below to disable peripheral header file inclusion */
#include "stm32l1xx_adc.h"
#include "stm32l1xx_crc.h"
#include "stm32l1xx_comp.h"
#include "stm32l1xx_dac.h"
#include "stm32l1xx_dbgmcu.h"
#include "stm32l1xx_dma.h"
#include "stm32l1xx_exti.h"
#include "stm32l1xx_flash.h"
#include "stm32l1xx_gpio.h"
#include "stm32l1xx_syscfg.h"
#include "stm32l1xx_i2c.h"
#include "stm32l1xx_iwdg.h"
#include "stm32l1xx_lcd.h"
#include "stm32l1xx_pwr.h"
#include "stm32l1xx_rcc.h"
#include "stm32l1xx_rtc.h"
#include "stm32l1xx_spi.h"
#include "stm32l1xx_tim.h"
#include "stm32l1xx_usart.h"
#include "stm32l1xx_wwdg.h"
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Uncomment the line below to expanse the "assert_param" macro in the
Standard Peripheral Library drivers code */
/* #define USE_FULL_ASSERT 1 */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function which reports
* the name of the source file and the source line number of the call
* that failed. If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */
#endif /* __STM32L1xx_CONF_H */
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,54 @@
/**
******************************************************************************
* @file Project/STM32L1xx_StdPeriph_Template/stm32l1xx_it.h
* @author MCD Application Team
* @version V1.0.3
* @date May-2013
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @copy
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L1xx_IT_H
#define __STM32L1xx_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void EXTI0_IRQHandler(void);
#ifdef __cplusplus
}
#endif
#endif /* __STM32L1xx_IT_H */
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,493 @@
/**
******************************************************************************
* @file STM32L152_Ex06_Linear_DISC\inc\tsl_conf_stm32l1xx.h
* @author MCD Application Team
* @version V1.0.3
* @date May-2013
* @brief Acquisition parameters for STM32L1xx products.
* @note This file must be copied in the application project and values
* changed for the application.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TSL_CONF_STM32L1xx_H
#define __TSL_CONF_STM32L1xx_H
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++ COMMON PARAMETERS ++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/** @defgroup Common_Parameters Common Parameters
* @{ */
//==============================================================================
// Number of elements
//==============================================================================
/** @defgroup Common_Parameters_Number_Of_Elements 01 - Number of elements
* @{ */
/** Total number of channels in application (range=1..255)
*/
#define TSLPRM_TOTAL_CHANNELS (3)
/** Total number of banks in application (range=1..255)
*/
#define TSLPRM_TOTAL_BANKS (1)
/** Total number of "Extended" TouchKeys in application (range=0..255)
*/
#define TSLPRM_TOTAL_TOUCHKEYS (0)
/** Total number of "Basic" TouchKeys in application (range=0..255)
*/
#define TSLPRM_TOTAL_TOUCHKEYS_B (0)
/** Total number of "Extended" Linear and Rotary sensors in application (range=0..255)
- Count also the 1-channel linear sensor used as TouchKey
*/
#define TSLPRM_TOTAL_LINROTS (1)
/** Total number of "Basic" Linear and Rotary sensors in application (range=0..255)
- Count also the 1-channel linear sensor used as TouchKey
*/
#define TSLPRM_TOTAL_LINROTS_B (0)
/** Total number of sensors/objects in application (range=1..255)
- Count all TouchKeys, Linear and Rotary sensors
*/
#define TSLPRM_TOTAL_OBJECTS (1)
/** @} Common_Parameters_Number_Of_Elements */
//==============================================================================
// Optional features
//==============================================================================
/** @defgroup Common_Parameters_Options 02 - Optional features
* @{ */
/** Record the last measure (0=No, 1=Yes)
- If No the measure is recalculated using the Reference and Delta
*/
#define TSLPRM_USE_MEAS (1)
/** Zone management usage (0=No, 1=Yes)
*/
#define TSLPRM_USE_ZONE (0)
/** Proximity detection usage (0=No, 1=Yes)
*/
#define TSLPRM_USE_PROX (0)
/** Use the Timer tick callback (0=No, 1=Yes)
- When equal to 1, the function TSL_CallBack_TimerTick must be defined in
the application code. It is called for each timer interruption.
*/
#define TSLPRM_USE_TIMER_CALLBACK (0)
/** Acquisition interrupt mode (0=No, 1=Yes)
- If No the TS interrupt is not used.
- If Yes the TS interrupt is used.
*/
#define TSLPRM_USE_ACQ_INTERRUPT (0)
/** @} Common_Parameters_Options */
//==============================================================================
// Acquisition limits
//==============================================================================
/** @defgroup Common_Parameters_Acquisition_Limits 03 - Acquisition limits
* @{ */
/** Minimum acquisition measurement (range=0..65535)
- This is the minimum acceptable value for the acquisition measure.
- The acquisition will be in error if the measure is below this value.
*/
#define TSLPRM_ACQ_MIN (50)
/** Maximum acquisition measurement (range=0..65535)
- This is the maximum acceptable value for the acquisition measure.
- The acquisition will be in error if the measure is above this value.
*/
#define TSLPRM_ACQ_MAX (4000)
/** @} Common_Parameters_Acquisition_Limits */
//==============================================================================
// Calibration
//==============================================================================
/** @defgroup Common_Parameters_Calibration 04 - Calibration
* @{ */
/** Number of calibration samples (range=4, 8, 16)
- Low value = faster calibration but less precision.
- High value = slower calibration but more precision.
*/
#define TSLPRM_CALIB_SAMPLES (8)
/** Delay in measurement samples before starting the calibration (range=0..40)
- This is usefull if a noise filter is used.
- Write 0 to disable the delay.
*/
#define TSLPRM_CALIB_DELAY (10)
/** @} Common_Parameters_Calibration */
//==============================================================================
// Thresholds for TouchKey sensors
//==============================================================================
/** @defgroup Common_Parameters_TouchKey_Thresholds 05 - Thresholds for TouchKey sensors
* @{ */
/** TouchKeys Proximity state input threshold (range=0..255)
- Enter Proximity state if delta is above
*/
#define TSLPRM_TKEY_PROX_IN_TH (20)
/** TouchKeys Proximity state output threshold (range=0..255)
- Exit Proximity state if delta is below
*/
#define TSLPRM_TKEY_PROX_OUT_TH (15)
/** TouchKeys Detect state input threshold (range=0..255)
- Enter Detect state if delta is above
*/
#define TSLPRM_TKEY_DETECT_IN_TH (30)
/** TouchKeys Detect state output threshold (range=0..255)
- Exit Detect state if delta is below
*/
#define TSLPRM_TKEY_DETECT_OUT_TH (25)
/** TouchKeys re-Calibration threshold (range=0..255)
- @warning The value is inverted in the sensor state machine
- Enter Calibration state if delta is below
*/
#define TSLPRM_TKEY_CALIB_TH (30)
/** TouchKey, Linear and Rotary sensors thresholds coefficient (range=0..4)
This multiplier coefficient is applied on Detect thresholds only.
- 0: feature disabled
- 1: thresholds x 2
- 2: thresholds x 4
- 3: thresholds x 8
- 4: thresholds x 16
*/
#define TSLPRM_COEFF_TH (0)
/** @} Common_Parameters_TouchKey_Thresholds */
//==============================================================================
// Thresholds for Linear and Rotary sensors
//==============================================================================
/** @defgroup Common_Parameters_LinRot_Thresholds 06 - Thresholds for Linear and Rotary sensors
* @{ */
/** Linear/Rotary Proximity state input threshold (range=0..255)
- Enter Proximity state if delta is above
*/
#define TSLPRM_LINROT_PROX_IN_TH (30)
/** Linear/Rotary Proximity state output threshold (range=0..255)
- Exit Proximity state if delta is below
*/
#define TSLPRM_LINROT_PROX_OUT_TH (20)
/** Linear/Rotary Detect state input threshold (range=0..255)
- Enter Detect state if delta is above
*/
#define TSLPRM_LINROT_DETECT_IN_TH (50)
/** Linear/Rotary Detect state output threshold (range=0..255)
- Exit Detect state if delta is below
*/
#define TSLPRM_LINROT_DETECT_OUT_TH (40)
/** Linear/Rotary re-Calibration threshold (range=0..255)
- @warning The value is inverted in the sensor state machine
- Enter Calibration state if delta is below
- A low absolute value will result in a higher sensitivity and thus some spurious
recalibration may be issued.
*/
#define TSLPRM_LINROT_CALIB_TH (50)
/** Linear/Rotary Delta normalization (0=No, 1=Yes)
- When this parameter is set, a coefficient is applied on all Delta of all sensors
in order to normalize them and to improve the position calculation.
- These coefficients must be defined in a constant table in the application (see Library examples).
- The MSB is the coefficient integer part, the LSB is the coefficient real part.
- Examples:
- To apply a factor 1.10:
0x01 to the MSB
0x1A to the LSB (0.10 x 256 = 25.6 -> rounded to 26 = 0x1A)
- To apply a factor 0.90:
0x00 to the MSB
0xE6 to the LSB (0.90 x 256 = 230.4 -> rounded to 230 = 0xE6)
- To apply no factor:
0x01 to the MSB
0x00 to the LSB
*/
#define TSLPRM_LINROT_USE_NORMDELTA (1)
/** @} Common_Parameters_LinRot_Thresholds */
//==============================================================================
// Linear/Rotary sensors used
//==============================================================================
/** @defgroup Common_Parameters_LinRot_Used 07 - Linear/Rotary sensors used
* @{ */
/** Select which Linear and Rotary sensors you use in your application.
- 0 = Not Used
- 1 = Used
LIN = Linear sensor
ROT = Rotary sensor
M = Mono electrodes design
H = Half-ended electrodes design
D = Dual electrodes design
*/
#define TSLPRM_USE_3CH_LIN_M (0)
#define TSLPRM_USE_3CH_LIN_H (1)
#define TSLPRM_USE_3CH_ROT_M (0)
#define TSLPRM_USE_4CH_LIN_M (0)
#define TSLPRM_USE_4CH_LIN_H (0)
#define TSLPRM_USE_4CH_ROT_M (0)
#define TSLPRM_USE_5CH_LIN_M (0)
#define TSLPRM_USE_5CH_LIN_H (0)
#define TSLPRM_USE_5CH_ROT_M (0)
#define TSLPRM_USE_5CH_ROT_D (0)
#define TSLPRM_USE_6CH_LIN_M (0)
#define TSLPRM_USE_6CH_LIN_H (0)
#define TSLPRM_USE_6CH_ROT_M (0)
/** @} Common_Parameters_LinRot_used */
//==============================================================================
// Linear/Rotary sensors position
//==============================================================================
/** @defgroup Common_Parameters_LinRot_Position 08 - Linear/Rotary sensors position
* @{ */
/** Position resolution in number of bits (range=1..8)
- A Low value will result in a low resolution and will be less subject to noise.
- A High value will result in a high resolution and will be more subject to noise.
*/
#define TSLPRM_LINROT_RESOLUTION (7)
/** Direction change threshold in position unit (range=0..255)
- Defines the default threshold used during the change direction process.
- A Low value will result in a faster direction change.
- A High value will result in a slower direction change.
*/
#define TSLPRM_LINROT_DIR_CHG_POS (10)
/** Direction change debounce (range=0..63)
- Defines the default integrator counter used during the change direction process.
- This counter is decremented when the same change in the position is detected and the direction will
change after this counter reaches zero.
- A Low value will result in a faster direction change.
- A High value will result in a slower direction change.
*/
#define TSLPRM_LINROT_DIR_CHG_DEB (1)
/** @} Common_Parameters_LinRot_Position */
//==============================================================================
// Debounce counters
//==============================================================================
/** @defgroup Common_Parameters_Debounce 09 - Debounce counters
* @{ */
/** Proximity state debounce in samples unit (range=0..63)
- A Low value will result in a higher sensitivity during the Proximity detection but with less noise filtering.
- A High value will result in improving the system noise immunity but will increase the system response time.
*/
#define TSLPRM_DEBOUNCE_PROX (3)
/** Detect state debounce in samples unit (range=0..63)
- A Low value will result in a higher sensitivity during the detection but with less noise filtering.
- A High value will result in improving the system noise immunity but will increase the system response time.
*/
#define TSLPRM_DEBOUNCE_DETECT (3)
/** Release state debounce in samples unit (range=0..63)
- A Low value will result in a higher sensitivity during the end-detection but with less noise filtering.
- A High value will result in a lower sensitivity during the end-detection but with more noise filtering.
*/
#define TSLPRM_DEBOUNCE_RELEASE (3)
/** Re-calibration state debounce in samples unit (range=0..63)
- A Low value will result in a higher sensitivity during the recalibration but with less noise filtering.
- A High value will result in a lower sensitivity during the recalibration but with more noise filtering.
*/
#define TSLPRM_DEBOUNCE_CALIB (3)
/** Error state debounce in samples unit (range=0..63)
- A Low value will result in a higher sensitivity to enter in error state.
- A High value will result in a lower sensitivity to enter in error state.
*/
#define TSLPRM_DEBOUNCE_ERROR (3)
/** @} Common_Parameters_Debounce */
//==============================================================================
// Environment Change System (ECS)
//==============================================================================
/** @defgroup Common_Parameters_ECS 10 - ECS
* @{ */
/** Environment Change System Slow K factor (range=0..255)
- The higher value is K, the faster is the response time.
*/
#define TSLPRM_ECS_K_SLOW (10)
/** Environment Change System Fast K factor (range=0..255)
- The higher value is K, the faster is the response time.
*/
#define TSLPRM_ECS_K_FAST (20)
/** Environment Change System delay in msec (range=0..5000)
- The ECS will be started after this delay and when all sensors are in Release state.
*/
#define TSLPRM_ECS_DELAY (500)
/** @} Common_Parameters_ECS */
//==============================================================================
// Detection Time Out (DTO)
//==============================================================================
/** @defgroup Common_Parameters_DTO 11 - DTO
* @{ */
/** Detection Time Out delay in seconds (range=0..63)
- Value 0: DTO processing not compiled in the code (to gain size if not used).
- Value 1: Default time out infinite.
- Value between 2 and 63: Default time out between value n-1 and n.
- Examples:
- With a DTO equal to 2, the time out is between 1s and 2s.
- With a DTO equal to 63, the time out is between 62s and 63s.
@note The DTO can be changed in run-time by the application only if the
default value is between 1 and 63.
*/
#define TSLPRM_DTO (10)
/** @} Common_Parameters_DTO */
//==============================================================================
// Detection Exclusion System (DXS)
//==============================================================================
/** @defgroup Common_Parameters_DXS 12 - DXS
* @{ */
/** Detection Exclusion System (0=No, 1=Yes)
*/
#define TSLPRM_USE_DXS (0)
/** @} Common_Parameters_DXS */
//==============================================================================
// Miscellaneous parameters
//==============================================================================
/** @defgroup Common_Parameters_Misc 13 - Miscellaneous
* @{ */
/** Timing tick frequency in Hz (range=125, 250, 500, 1000, 2000)
- Result to a timing interrupt respectively every 8ms, 4ms, 2ms, 1ms, 0.5ms
*/
#define TSLPRM_TICK_FREQ (2000)
/** @} Common_Parameters_Misc */
/** @} Common_Parameters */
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++ MCU PARAMETERS ++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/** @defgroup STM32L1xx_Parameters STM32L1xx Parameters
* @{ */
/** @defgroup STM32L1xx_Parameters_Misc 01 - Miscellaneous
* @{ */
/** Shield with a channel (0=No, 1=Yes)
*/
#define TSLPRM_USE_SHIELD (0)
/** IOs default mode when no on-going acquisition (range=0..1)
- 0: Output push-pull low
- 1: Input floating
*/
#define TSLPRM_IODEF (0)
/** Master timer prescaler for HW acquisition only (range=0..65535)
- Divide the timer input clock by this value plus one
*/
#define TSLPRM_TIM_PRESCALER (0)
/** Master timer reload value for HW acquisition only (range=4..65534, even number)
- Set the auto-reload value for the center aligned counter
*/
#define TSLPRM_TIM_RELOAD (64)
/** IT disabling for IO protection for SW acquisition only (range=0..1)
- 0: IO not protected
- 1: IO protected
*/
#define TSLPRM_PROTECT_IO_ACCESS (1)
/** Which GPIO will be used for SW acquisition only (range=0..1)
- 0: Not used
- 1: Used
*/
#define TSLPRM_USE_GPIOA (1)
#define TSLPRM_USE_GPIOB (1)
#define TSLPRM_USE_GPIOC (1)
#define TSLPRM_USE_GPIOF (0)
#define TSLPRM_USE_GPIOG (0)
/** @} STM32L1xx_Parameters_Misc */
/** @} STM32L1xx_Parameters */
// DO NOT REMOVE !!!
#include "tsl_check_config.h"
#endif /* __TSL_CONF_STM32L1xx_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,87 @@
/**
******************************************************************************
* @file STM32L152_Ex06_Linear_DISC\inc\tsl_user.h
* @author MCD Application Team
* @version V1.0.3
* @date May-2013
* @brief Touch-Sensing user configuration and api file.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TSL_USER_H
#define __TSL_USER_H
#include "tsl.h"
// LEDs definition on STM32L152B-DISC board
// PB7 = LED_GREEN
#define LED_GREEN_TOGGLE {GPIOB->ODR ^= (1<<7);}
#define LED_GREEN_OFF {GPIOB->ODR &= ~(1<<7);}
#define LED_GREEN_ON {GPIOB->ODR |= (1<<7);}
// PB6 = LED_BLUE
#define LED_BLUE_TOGGLE {GPIOB->ODR ^= (1<<6);}
#define LED_BLUE_OFF {GPIOB->ODR &= ~(1<<6);}
#define LED_BLUE_ON {GPIOB->ODR |= (1<<6);}
//==============================================================================
// IOs definition
//==============================================================================
// Channel IOs definition
#define CHANNEL_0_SRC ((uint32_t)(GR2))
#define CHANNEL_0_DEST (0)
#define CHANNEL_0_SAMPLE_CONFIG TSL_GROUP2_IO2
#define CHANNEL_0_CHANNEL_CONFIG TSL_GROUP2_IO1
#define CHANNEL_1_SRC ((uint32_t)(GR9))
#define CHANNEL_1_DEST (1)
#define CHANNEL_1_SAMPLE_CONFIG TSL_GROUP9_IO2
#define CHANNEL_1_CHANNEL_CONFIG TSL_GROUP9_IO1
#define CHANNEL_2_SRC ((uint32_t)(GR3))
#define CHANNEL_2_DEST (2)
#define CHANNEL_2_SAMPLE_CONFIG TSL_GROUP3_IO2
#define CHANNEL_2_CHANNEL_CONFIG TSL_GROUP3_IO1
// Banks definition
#define BANK_0_NBCHANNELS (3)
#define BANK_0_INDEX (0) // Index of 1st channel used
#define BANK_0_SHIELD_SAMPLE (0)
#define BANK_0_SHIELD_CHANNEL (0)
// User Parameters
extern TSL_ObjectGroup_T MyObjGroup;
extern CONST TSL_Object_T MyObjects[];
extern CONST TSL_Bank_T MyBanks[];
extern CONST TSL_LinRot_T MyLinRots[];
void MyLinRots_ErrorStateProcess(void);
void MyLinRots_OffStateProcess(void);
void TSL_user_Init(void);
TSL_Status_enum_T TSL_user_Action(void);
void ProcessSensors(void);
void ProcessSensorsButtons(void);
#endif /* __TSL_USER_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/