diff options
Diffstat (limited to 'demos')
-rw-r--r-- | demos/ARMCM3-STM32L152-DISCOVERY/halconf.h | 10 | ||||
-rw-r--r-- | demos/ARMCM3-STM32L152-DISCOVERY/main.c | 153 | ||||
-rw-r--r-- | demos/ARMCM3-STM32L152-DISCOVERY/mcuconf.h | 11 |
3 files changed, 23 insertions, 151 deletions
diff --git a/demos/ARMCM3-STM32L152-DISCOVERY/halconf.h b/demos/ARMCM3-STM32L152-DISCOVERY/halconf.h index 0ed6eed8b..ac3ae4187 100644 --- a/demos/ARMCM3-STM32L152-DISCOVERY/halconf.h +++ b/demos/ARMCM3-STM32L152-DISCOVERY/halconf.h @@ -38,14 +38,14 @@ * @brief Enables the PAL subsystem.
*/
#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
-#define HAL_USE_PAL TRUE
+#define HAL_USE_PAL FALSE
#endif
/**
* @brief Enables the ADC subsystem.
*/
#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
-#define HAL_USE_ADC TRUE
+#define HAL_USE_ADC FALSE
#endif
/**
@@ -94,7 +94,7 @@ * @brief Enables the PWM subsystem.
*/
#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
-#define HAL_USE_PWM TRUE
+#define HAL_USE_PWM FALSE
#endif
/**
@@ -108,7 +108,7 @@ * @brief Enables the SERIAL subsystem.
*/
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL TRUE
+#define HAL_USE_SERIAL FALSE
#endif
/**
@@ -122,7 +122,7 @@ * @brief Enables the SPI subsystem.
*/
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_SPI TRUE
+#define HAL_USE_SPI FALSE
#endif
/**
diff --git a/demos/ARMCM3-STM32L152-DISCOVERY/main.c b/demos/ARMCM3-STM32L152-DISCOVERY/main.c index ff9c4ec70..a56f81efa 100644 --- a/demos/ARMCM3-STM32L152-DISCOVERY/main.c +++ b/demos/ARMCM3-STM32L152-DISCOVERY/main.c @@ -22,135 +22,6 @@ #include "hal.h"
#include "test.h"
-static void pwmpcb(PWMDriver *pwmp);
-static void adccb(ADCDriver *adcp, adcsample_t *buffer, size_t n);
-static void spicb(SPIDriver *spip);
-
-/* Total number of channels to be sampled by a single ADC operation.*/
-#define ADC_GRP1_NUM_CHANNELS 2
-
-/* Depth of the conversion buffer, channels are sampled four times each.*/
-#define ADC_GRP1_BUF_DEPTH 4
-
-/*
- * ADC samples buffer.
- */
-static adcsample_t samples[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH];
-
-/*
- * ADC conversion group.
- * Mode: Linear buffer, 4 samples of 2 channels, SW triggered.
- * Channels: IN10 (41.5 cycles sample time)
- * Sensor (239.5 cycles sample time)
- */
-static const ADCConversionGroup adcgrpcfg = {
- FALSE,
- ADC_GRP1_NUM_CHANNELS,
- adccb,
- /* HW dependent part.*/
- 0,
- ADC_CR2_TSVREFE,
- ADC_SMPR1_SMP_AN10(ADC_SAMPLE_41P5) | ADC_SMPR1_SMP_SENSOR(ADC_SAMPLE_239P5),
- 0,
- ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS),
- 0,
- ADC_SQR3_SQ2_N(ADC_CHANNEL_IN10) | ADC_SQR3_SQ1_N(ADC_CHANNEL_SENSOR)
-};
-
-/*
- * PWM configuration structure.
- * Cyclic callback enabled, channels 3 and 4 enabled without callbacks,
- * the active state is a logic one.
- */
-static PWMConfig pwmcfg = {
- 10000, /* 10KHz PWM clock frequency. */
- 10000, /* PWM period 1S (in ticks). */
- pwmpcb,
- {
- {PWM_OUTPUT_DISABLED, NULL},
- {PWM_OUTPUT_DISABLED, NULL},
- {PWM_OUTPUT_ACTIVE_HIGH, NULL},
- {PWM_OUTPUT_ACTIVE_HIGH, NULL}
- },
- /* HW dependent part.*/
- 0,
-#if STM32_PWM_USE_ADVANCED
- 0
-#endif
-};
-
-/*
- * SPI configuration structure.
- * Maximum speed (12MHz), CPHA=0, CPOL=0, 16bits frames, MSb transmitted first.
- * The slave select line is the pin GPIOA_SPI1NSS on the port GPIOA.
- */
-static const SPIConfig spicfg = {
- spicb,
- /* HW dependent part.*/
- GPIOA,
- GPIOA_SPI1NSS,
- SPI_CR1_DFF
-};
-
-/*
- * PWM cyclic callback.
- * A new ADC conversion is started.
- */
-static void pwmpcb(PWMDriver *pwmp) {
-
- (void)pwmp;
-
- /* Starts an asynchronous ADC conversion operation, the conversion
- will be executed in parallel to the current PWM cycle and will
- terminate before the next PWM cycle.*/
- chSysLockFromIsr();
- adcStartConversionI(&ADCD1, &adcgrpcfg, samples, ADC_GRP1_BUF_DEPTH);
- chSysUnlockFromIsr();
-}
-
-/*
- * ADC end conversion callback.
- * The PWM channels are reprogrammed using the latest ADC samples.
- * The latest samples are transmitted into a single SPI transaction.
- */
-void adccb(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
-
- (void) buffer; (void) n;
- /* Note, only in the ADC_COMPLETE state because the ADC driver fires an
- intermediate callback when the buffer is half full.*/
- if (adcp->state == ADC_COMPLETE) {
- adcsample_t avg_ch1, avg_ch2;
-
- /* Calculates the average values from the ADC samples.*/
- avg_ch1 = (samples[0] + samples[2] + samples[4] + samples[6]) / 4;
- avg_ch2 = (samples[1] + samples[3] + samples[5] + samples[7]) / 4;
-
- chSysLockFromIsr();
-
- /* Changes the channels pulse width, the change will be effective
- starting from the next cycle.*/
- pwmEnableChannelI(&PWMD3, 2, PWM_FRACTION_TO_WIDTH(&PWMD3, 4096, avg_ch1));
- pwmEnableChannelI(&PWMD3, 3, PWM_FRACTION_TO_WIDTH(&PWMD3, 4096, avg_ch2));
-
- /* SPI slave selection and transmission start.*/
- spiSelectI(&SPID1);
- spiStartSendI(&SPID1, ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH, samples);
-
- chSysUnlockFromIsr();
- }
-}
-
-/*
- * SPI end transfer callback.
- */
-static void spicb(SPIDriver *spip) {
-
- /* On transfer end just releases the slave select line.*/
- chSysLockFromIsr();
- spiUnselectI(spip);
- chSysUnlockFromIsr();
-}
-
/*
* This is a periodic thread that does absolutely nothing except increasing
* a seconds counter.
@@ -184,27 +55,27 @@ int main(void) { /*
* Activates the serial driver 1 using the driver default configuration.
*/
- sdStart(&SD1, NULL);
+// sdStart(&SD1, NULL);
/*
* If the user button is pressed after the reset then the test suite is
* executed immediately before activating the various device drivers in
* order to not alter the benchmark scores.
*/
- if (palReadPad(GPIOA, GPIOA_BUTTON))
- TestThread(&SD1);
+// if (palReadPad(GPIOA, GPIOA_BUTTON))
+// TestThread(&SD1);
/*
* Initializes the SPI driver 1.
*/
- spiStart(&SPID1, &spicfg);
+// spiStart(&SPID1, &spicfg);
/*
* Initializes the ADC driver 1.
* The pin PC0 on the port GPIOC is programmed as analog input.
*/
- adcStart(&ADCD1, NULL);
- palSetGroupMode(GPIOC, PAL_PORT_BIT(0), PAL_MODE_INPUT_ANALOG);
+// adcStart(&ADCD1, NULL);
+// palSetGroupMode(GPIOC, PAL_PORT_BIT(0), PAL_MODE_INPUT_ANALOG);
/*
* Initializes the PWM driver 1, re-routes the TIM3 outputs, programs the
@@ -212,10 +83,10 @@ int main(void) { * Note, the AFIO access routes the TIM3 output pins on the PC6...PC9
* where the LEDs are connected.
*/
- pwmStart(&PWMD3, &pwmcfg);
- AFIO->MAPR |= AFIO_MAPR_TIM3_REMAP_0 | AFIO_MAPR_TIM3_REMAP_1;
- palSetGroupMode(GPIOC, PAL_PORT_BIT(GPIOC_LED3) | PAL_PORT_BIT(GPIOC_LED4),
- PAL_MODE_STM32_ALTERNATE_PUSHPULL);
+// pwmStart(&PWMD3, &pwmcfg);
+// AFIO->MAPR |= AFIO_MAPR_TIM3_REMAP_0 | AFIO_MAPR_TIM3_REMAP_1;
+// palSetGroupMode(GPIOC, PAL_PORT_BIT(GPIOC_LED3) | PAL_PORT_BIT(GPIOC_LED4),
+// PAL_MODE_STM32_ALTERNATE_PUSHPULL);
/*
* Creates the example thread.
@@ -229,8 +100,8 @@ int main(void) { * driver 1.
*/
while (TRUE) {
- if (palReadPad(GPIOA, GPIOA_BUTTON))
- TestThread(&SD1);
+// if (palReadPad(GPIOA, GPIOA_BUTTON))
+// TestThread(&SD1);
chThdSleepMilliseconds(500);
}
}
diff --git a/demos/ARMCM3-STM32L152-DISCOVERY/mcuconf.h b/demos/ARMCM3-STM32L152-DISCOVERY/mcuconf.h index 0461fd201..e063a7cb7 100644 --- a/demos/ARMCM3-STM32L152-DISCOVERY/mcuconf.h +++ b/demos/ARMCM3-STM32L152-DISCOVERY/mcuconf.h @@ -19,7 +19,7 @@ */
/*
- * STM32 drivers configuration.
+ * STM32L1xx drivers configuration.
* The following settings override the default settings present in
* the various device driver implementation headers.
* Note that the settings for each driver only have effect if the whole
@@ -35,14 +35,15 @@ /*
* HAL driver system settings.
*/
+#define STM32_VOS STM32_VOS_1P8
+#define STM32_MSIRANGE STM32_MSIRANGE_2M
#define STM32_SW STM32_SW_PLL
-#define STM32_PLLSRC STM32_PLLSRC_HSE
-#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
-#define STM32_PLLMUL_VALUE 3
+#define STM32_PLLSRC STM32_PLLSRC_HSI
+#define STM32_PLLMUL_VALUE 6
+#define STM32_PLLDIV_VALUE 3
#define STM32_HPRE STM32_HPRE_DIV1
#define STM32_PPRE1 STM32_PPRE1_DIV1
#define STM32_PPRE2 STM32_PPRE2_DIV1
-#define STM32_ADCPRE STM32_ADCPRE_DIV2
#define STM32_MCO STM32_MCO_NOCLOCK
/*
|