aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os/hal/include/hal_adc.h43
-rw-r--r--os/hal/include/hal_dac.h39
-rw-r--r--os/hal/include/hal_i2s.h25
-rw-r--r--os/hal/include/hal_spi.h25
-rw-r--r--os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c6
-rw-r--r--os/hal/ports/STM32/LLD/SPIv2/hal_i2s_lld.c4
-rw-r--r--os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c6
-rw-r--r--os/hal/ports/STM32/LLD/SPIv3/hal_i2s_lld.c4
-rw-r--r--os/hal/ports/STM32/LLD/SPIv3/hal_spi_lld.c12
-rw-r--r--os/hal/src/hal_adc.c1
-rw-r--r--readme.txt7
-rw-r--r--testhal/STM32/STM32F0xx/ADC/main.c9
-rw-r--r--testhal/STM32/STM32F1xx/ADC/main.c9
-rw-r--r--testhal/STM32/STM32F37x/ADC/main.c9
-rw-r--r--testhal/STM32/STM32F37x/SDADC/main.c9
-rw-r--r--testhal/STM32/STM32F3xx/ADC/main.c9
-rw-r--r--testhal/STM32/STM32F3xx/ADC_DUAL/main.c9
-rw-r--r--testhal/STM32/STM32F3xx/DAC/main.c10
-rw-r--r--testhal/STM32/STM32F4xx/ADC/main.c9
-rw-r--r--testhal/STM32/STM32F4xx/DAC/main.c10
-rw-r--r--testhal/STM32/STM32F4xx/DAC_DUAL/main.c10
-rw-r--r--testhal/STM32/STM32F4xx/I2S/main.c13
-rw-r--r--testhal/STM32/STM32F7xx/GPT-ADC/main.c10
-rw-r--r--testhal/STM32/STM32L0xx/ADC/main.c9
-rw-r--r--testhal/STM32/STM32L1xx/ADC/main.c9
-rw-r--r--testhal/STM32/STM32L4xx/ADC/Makefile2
-rw-r--r--testhal/STM32/STM32L4xx/ADC/debug/STM32L4xx-ADC (OpenOCD, Flash and Run).launch104
-rw-r--r--testhal/STM32/STM32L4xx/ADC/main.c11
-rw-r--r--testhal/STM32/multi/DAC/main.c10
-rwxr-xr-xtesthal/STM32/multi/SPI/main.c2
30 files changed, 233 insertions, 202 deletions
diff --git a/os/hal/include/hal_adc.h b/os/hal/include/hal_adc.h
index 8ccc8241e..57797c7ee 100644
--- a/os/hal/include/hal_adc.h
+++ b/os/hal/include/hal_adc.h
@@ -104,11 +104,8 @@ typedef struct hal_adc_configuration_group ADCConversionGroup;
* @brief Type of an ADC notification callback.
*
* @param[in] adcp pointer to the @p ADCDriver object triggering the
- * callback
- * @param[in] buffer pointer to the most recent samples data
- * @param[in] n number of buffer rows available starting from @p buffer
*/
-typedef void (*adccallback_t)(ADCDriver *adcp, adcsample_t *buffer, size_t n);
+typedef void (*adccallback_t)(ADCDriver *adcp);
/**
* @brief Type of an ADC error callback.
@@ -204,6 +201,26 @@ struct hal_adc_driver {
/*===========================================================================*/
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
+ * @brief Buffer state.
+ * @note This function is meant to be called from the SPI callback only.
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ * @return The buffer state.
+ * @retval false if the driver filled/sent the first half of the
+ * buffer.
+ * @retval true if the driver filled/sent the second half of the
+ * buffer.
+ *
+ * @special
+ */
+#define adcIsBufferComplete(adcp) ((bool)((adcp)->state == ADC_COMPLETE))
+/** @} */
+
+/**
* @name Low level driver helper macros
* @{
*/
@@ -275,7 +292,7 @@ struct hal_adc_driver {
*/
#define _adc_isr_half_code(adcp) { \
if ((adcp)->grpp->end_cb != NULL) { \
- (adcp)->grpp->end_cb(adcp, (adcp)->samples, (adcp)->depth / 2); \
+ (adcp)->grpp->end_cb(adcp); \
} \
}
@@ -297,15 +314,10 @@ struct hal_adc_driver {
if ((adcp)->grpp->circular) { \
/* Callback handling.*/ \
if ((adcp)->grpp->end_cb != NULL) { \
- if ((adcp)->depth > 1) { \
- /* Invokes the callback passing the 2nd half of the buffer.*/ \
- size_t half = (adcp)->depth / 2; \
- size_t half_index = half * (adcp)->grpp->num_channels; \
- (adcp)->grpp->end_cb(adcp, (adcp)->samples + half_index, half); \
- } \
- else { \
- /* Invokes the callback passing the whole buffer.*/ \
- (adcp)->grpp->end_cb(adcp, (adcp)->samples, (adcp)->depth); \
+ (adcp)->state = ADC_COMPLETE; \
+ (adcp)->grpp->end_cb(adcp); \
+ if ((adcp)->state == ADC_COMPLETE) { \
+ (adcp)->state = ADC_ACTIVE; \
} \
} \
} \
@@ -314,8 +326,7 @@ struct hal_adc_driver {
adc_lld_stop_conversion(adcp); \
if ((adcp)->grpp->end_cb != NULL) { \
(adcp)->state = ADC_COMPLETE; \
- /* Invoke the callback passing the whole buffer.*/ \
- (adcp)->grpp->end_cb(adcp, (adcp)->samples, (adcp)->depth); \
+ (adcp)->grpp->end_cb(adcp); \
if ((adcp)->state == ADC_COMPLETE) { \
(adcp)->state = ADC_READY; \
(adcp)->grpp = NULL; \
diff --git a/os/hal/include/hal_dac.h b/os/hal/include/hal_dac.h
index 6533f35d6..403df4970 100644
--- a/os/hal/include/hal_dac.h
+++ b/os/hal/include/hal_dac.h
@@ -99,11 +99,8 @@ typedef struct hal_dac_conversion_group DACConversionGroup;
* @brief DAC notification callback type.
*
* @param[in] dacp pointer to the @p DACDriver object triggering the
- * @param[in] buffer pointer to the next semi-buffer to be filled
- * @param[in] n number of buffer rows available starting from @p buffer
- * callback
*/
-typedef void (*daccallback_t)(DACDriver *dacp, dacsample_t *buffer, size_t n);
+typedef void (*daccallback_t)(DACDriver *dacp);
/**
* @brief DAC error callback type.
@@ -193,6 +190,21 @@ struct hal_dac_driver {
* @name Low level driver helper macros
* @{
*/
+/**
+ * @brief Buffer state.
+ * @note This function is meant to be called from the DAC callback only.
+ *
+ * @param[in] dacp pointer to the @p DACDriver object
+ * @return The buffer state.
+ * @retval false if the driver filled/sent the first half of the
+ * buffer.
+ * @retval true if the driver filled/sent the second half of the
+ * buffer.
+ *
+ * @special
+ */
+#define dacIsBufferComplete(dacp) ((bool)((dacp)->state == DAC_COMPLETE))
+
#if (DAC_USE_WAIT == TRUE) || defined(__DOXYGEN__)
/**
* @brief Waits for operation completion.
@@ -274,7 +286,7 @@ struct hal_dac_driver {
*/
#define _dac_isr_half_code(dacp) { \
if ((dacp)->grpp->end_cb != NULL) { \
- (dacp)->grpp->end_cb(dacp, (dacp)->samples, (dacp)->depth / 2); \
+ (dacp)->grpp->end_cb(dacp); \
} \
}
@@ -282,7 +294,6 @@ struct hal_dac_driver {
* @brief Common ISR code, full buffer event.
* @details This code handles the portable part of the ISR code:
* - Callback invocation.
- * - Waiting thread wakeup, if any.
* - Driver state transitions.
* .
* @note This macro is meant to be used in the low level drivers
@@ -293,17 +304,11 @@ struct hal_dac_driver {
* @notapi
*/
#define _dac_isr_full_code(dacp) { \
- if ((dacp)->grpp->end_cb != NULL) { \
- if ((dacp)->depth > 1) { \
- /* Invokes the callback passing the 2nd half of the buffer.*/ \
- size_t half = (dacp)->depth / 2; \
- size_t half_index = half * (dacp)->grpp->num_channels; \
- (dacp)->grpp->end_cb(dacp, (dacp)->samples + half_index, half); \
- } \
- else { \
- /* Invokes the callback passing the whole buffer.*/ \
- (dacp)->grpp->end_cb(dacp, (dacp)->samples, (dacp)->depth); \
- } \
+ if ((dacp)->grpp->end_cb) { \
+ (dacp)->state = DAC_COMPLETE; \
+ (dacp)->grpp->end_cb(dacp); \
+ if ((dacp)->state == DAC_COMPLETE) \
+ (dacp)->state = DAC_ACTIVE; \
} \
}
diff --git a/os/hal/include/hal_i2s.h b/os/hal/include/hal_i2s.h
index 9811423f5..1dccaaa1e 100644
--- a/os/hal/include/hal_i2s.h
+++ b/os/hal/include/hal_i2s.h
@@ -76,10 +76,8 @@ typedef struct hal_i2s_config I2SConfig;
* @brief I2S notification callback type.
*
* @param[in] i2sp pointer to the @p I2SDriver object
- * @param[in] offset offset in buffers of the data to read/write
- * @param[in] n number of samples to read/write
*/
-typedef void (*i2scallback_t)(I2SDriver *i2sp, size_t offset, size_t n);
+typedef void (*i2scallback_t)(I2SDriver *i2sp);
/* Including the low level driver header, it exports information required
for completing types.*/
@@ -136,6 +134,21 @@ struct hal_i2s_config {
* @{
*/
/**
+ * @brief Buffer state.
+ * @note This function is meant to be called from the SPI callback only.
+ *
+ * @param[in] i2sp pointer to the @p I2SDriver object
+ * @return The buffer state.
+ * @retval false if the driver filled/sent the first half of the
+ * buffer.
+ * @retval true if the driver filled/sent the second half of the
+ * buffer.
+ *
+ * @special
+ */
+#define i2sIsBufferComplete(i2sp) ((bool)((i2sp)->state == I2S_COMPLETE))
+
+/**
* @brief Starts a I2S data exchange.
*
* @param[in] i2sp pointer to the @p I2SDriver object
@@ -175,7 +188,7 @@ struct hal_i2s_config {
*/
#define _i2s_isr_half_code(i2sp) { \
if ((i2sp)->config->end_cb != NULL) { \
- (i2sp)->config->end_cb(i2sp, 0, (i2sp)->config->size / 2); \
+ (i2sp)->config->end_cb(i2sp); \
} \
}
@@ -195,9 +208,7 @@ struct hal_i2s_config {
#define _i2s_isr_full_code(i2sp) { \
if ((i2sp)->config->end_cb) { \
(i2sp)->state = I2S_COMPLETE; \
- (i2sp)->config->end_cb(i2sp, \
- (i2sp)->config->size / 2, \
- (i2sp)->config->size / 2); \
+ (i2sp)->config->end_cb(i2sp); \
if ((i2sp)->state == I2S_COMPLETE) { \
(i2sp)->state = I2S_ACTIVE; \
} \
diff --git a/os/hal/include/hal_spi.h b/os/hal/include/hal_spi.h
index 4d2ebdefb..57f63e13c 100644
--- a/os/hal/include/hal_spi.h
+++ b/os/hal/include/hal_spi.h
@@ -225,6 +225,21 @@ struct hal_spi_driver {
* @name Macro Functions
* @{
*/
+/**
+ * @brief Buffer state.
+ * @note This function is meant to be called from the SPI callback only.
+ *
+ * @param[in] spip pointer to the @p SPIDriver object
+ * @return The buffer state.
+ * @retval false if the driver filled/sent the first half of the
+ * buffer.
+ * @retval true if the driver filled/sent the second half of the
+ * buffer.
+ *
+ * @special
+ */
+#define spiIsBufferComplete(spip) ((bool)((spip)->state == SPI_COMPLETE))
+
#if (SPI_SELECT_MODE == SPI_SELECT_MODE_LLD) || defined(__DOXYGEN__)
/**
* @brief Asserts the slave select signal and prepares for transfers.
@@ -408,7 +423,7 @@ do { \
#endif /* !SPI_USE_WAIT */
/**
- * @brief Common ISR code.
+ * @brief Common ISR code when circular mode is not supported.
* @details This code handles the portable part of the ISR code:
* - Callback invocation.
* - Waiting thread wakeup, if any.
@@ -434,7 +449,7 @@ do { \
}
/**
- * @brief Common ISR code in circular mode.
+ * @brief Half buffer filled ISR code in circular mode.
* @details This code handles the portable part of the ISR code:
* - Callback invocation.
* .
@@ -445,14 +460,14 @@ do { \
*
* @notapi
*/
-#define _spi_isr_code_half1(spip) { \
+#define _spi_isr_half_code(spip) { \
if ((spip)->config->end_cb) { \
(spip)->config->end_cb(spip); \
} \
}
/**
- * @brief Common ISR code in circular mode.
+ * @brief Full buffer filled ISR code in circular mode.
* @details This code handles the portable part of the ISR code:
* - Callback invocation.
* - Driver state transitions.
@@ -464,7 +479,7 @@ do { \
*
* @notapi
*/
-#define _spi_isr_code_half2(spip) { \
+#define _spi_isr_full_code(spip) { \
if ((spip)->config->end_cb) { \
(spip)->state = SPI_COMPLETE; \
(spip)->config->end_cb(spip); \
diff --git a/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c b/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c
index b160433cd..7cfe5d9a1 100644
--- a/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c
+++ b/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c
@@ -143,11 +143,11 @@ static void spi_lld_serve_rx_interrupt(SPIDriver *spip, uint32_t flags) {
if (spip->config->circular) {
if ((flags & STM32_DMA_ISR_HTIF) != 0U) {
/* Half buffer interrupt.*/
- _spi_isr_code_half1(spip);
+ _spi_isr_half_code(spip);
}
- else {
+ if ((flags & STM32_DMA_ISR_TCIF) != 0U) {
/* End buffer interrupt.*/
- _spi_isr_code_half2(spip);
+ _spi_isr_full_code(spip);
}
}
else {
diff --git a/os/hal/ports/STM32/LLD/SPIv2/hal_i2s_lld.c b/os/hal/ports/STM32/LLD/SPIv2/hal_i2s_lld.c
index f425805a4..83258538e 100644
--- a/os/hal/ports/STM32/LLD/SPIv2/hal_i2s_lld.c
+++ b/os/hal/ports/STM32/LLD/SPIv2/hal_i2s_lld.c
@@ -198,11 +198,11 @@ static void i2s_lld_serve_tx_interrupt(I2SDriver *i2sp, uint32_t flags) {
level driver.*/
if ((flags & STM32_DMA_ISR_TCIF) != 0) {
/* Transfer complete processing.*/
- _i2s_isr_full_code(i2sp);
+ _i2s_isr_code_half2(i2sp);
}
else if ((flags & STM32_DMA_ISR_HTIF) != 0) {
/* Half transfer processing.*/
- _i2s_isr_half_code(i2sp);
+ _i2s_isr_code_half1(i2sp);
}
}
#endif
diff --git a/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c b/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c
index dd718d385..26e381c77 100644
--- a/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c
+++ b/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c
@@ -143,11 +143,11 @@ static void spi_lld_serve_rx_interrupt(SPIDriver *spip, uint32_t flags) {
if (spip->config->circular) {
if ((flags & STM32_DMA_ISR_HTIF) != 0U) {
/* Half buffer interrupt.*/
- _spi_isr_code_half1(spip);
+ _spi_isr_half_code(spip);
}
- else {
+ if ((flags & STM32_DMA_ISR_TCIF) != 0U) {
/* End buffer interrupt.*/
- _spi_isr_code_half2(spip);
+ _spi_isr_full_code(spip);
}
}
else {
diff --git a/os/hal/ports/STM32/LLD/SPIv3/hal_i2s_lld.c b/os/hal/ports/STM32/LLD/SPIv3/hal_i2s_lld.c
index f425805a4..83258538e 100644
--- a/os/hal/ports/STM32/LLD/SPIv3/hal_i2s_lld.c
+++ b/os/hal/ports/STM32/LLD/SPIv3/hal_i2s_lld.c
@@ -198,11 +198,11 @@ static void i2s_lld_serve_tx_interrupt(I2SDriver *i2sp, uint32_t flags) {
level driver.*/
if ((flags & STM32_DMA_ISR_TCIF) != 0) {
/* Transfer complete processing.*/
- _i2s_isr_full_code(i2sp);
+ _i2s_isr_code_half2(i2sp);
}
else if ((flags & STM32_DMA_ISR_HTIF) != 0) {
/* Half transfer processing.*/
- _i2s_isr_half_code(i2sp);
+ _i2s_isr_code_half1(i2sp);
}
}
#endif
diff --git a/os/hal/ports/STM32/LLD/SPIv3/hal_spi_lld.c b/os/hal/ports/STM32/LLD/SPIv3/hal_spi_lld.c
index 86c2440e9..994c31d14 100644
--- a/os/hal/ports/STM32/LLD/SPIv3/hal_spi_lld.c
+++ b/os/hal/ports/STM32/LLD/SPIv3/hal_spi_lld.c
@@ -96,11 +96,11 @@ static void spi_lld_serve_bdma_rx_interrupt(SPIDriver *spip, uint32_t flags) {
if (spip->config->circular) {
if ((flags & STM32_BDMA_ISR_HTIF) != 0U) {
/* Half buffer interrupt.*/
- _spi_isr_code_half1(spip);
+ _spi_isr_half_code(spip);
}
- else {
+ if ((flags & STM32_BDMA_ISR_TCIF) != 0U) {
/* End buffer interrupt.*/
- _spi_isr_code_half2(spip);
+ _spi_isr_full_code(spip);
}
}
else {
@@ -159,11 +159,11 @@ static void spi_lld_serve_dma_rx_interrupt(SPIDriver *spip, uint32_t flags) {
if (spip->config->circular) {
if ((flags & STM32_DMA_ISR_HTIF) != 0U) {
/* Half buffer interrupt.*/
- _spi_isr_code_half1(spip);
+ _spi_isr_half_code(spip);
}
- else {
+ if ((flags & STM32_DMA_ISR_TCIF) != 0U) {
/* End buffer interrupt.*/
- _spi_isr_code_half2(spip);
+ _spi_isr_full_code(spip);
}
}
else {
diff --git a/os/hal/src/hal_adc.c b/os/hal/src/hal_adc.c
index 4f8ed0dbc..41234ef7a 100644
--- a/os/hal/src/hal_adc.c
+++ b/os/hal/src/hal_adc.c
@@ -181,7 +181,6 @@ void adcStartConversionI(ADCDriver *adcp,
osalDbgCheck((adcp != NULL) && (grpp != NULL) && (samples != NULL) &&
(depth > 0U) && ((depth == 1U) || ((depth & 1U) == 0U)));
osalDbgAssert((adcp->state == ADC_READY) ||
- (adcp->state == ADC_COMPLETE) ||
(adcp->state == ADC_ERROR),
"not ready");
diff --git a/readme.txt b/readme.txt
index 2b0694eda..29e929970 100644
--- a/readme.txt
+++ b/readme.txt
@@ -75,6 +75,13 @@
*****************************************************************************
*** Next ***
+- NEW: The callback of drivers with circular buffers (ADC, DAC, I2S, SPI) has
+ been simplified, no parameters. A driver function xxxIsBufferComplete()
+ has been added to determine if it is the half buffer callback or the
+ final callback.
+- NEW: ADC driver state machine change, now the state ADC_COMPLETE is set
+ before calling the 2nd callback even in circular mode. This has been
+ done for consistency with other drivers with circular buffers.
- NEW: Low level drivers simplification. There is a new template of LLD, now
driver and configuration types are defined in the HLD, LLD just exports
macros with the fields to be added to the structures.
diff --git a/testhal/STM32/STM32F0xx/ADC/main.c b/testhal/STM32/STM32F0xx/ADC/main.c
index b7cf2bbde..109150b6a 100644
--- a/testhal/STM32/STM32F0xx/ADC/main.c
+++ b/testhal/STM32/STM32F0xx/ADC/main.c
@@ -30,14 +30,13 @@ static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
* ADC streaming callback.
*/
size_t nx = 0, ny = 0;
-static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
+static void adccallback(ADCDriver *adcp) {
- (void)adcp;
- if (samples2 == buffer) {
- nx += n;
+ if (adcIsBufferComplete(adcp)) {
+ nx += 1;
}
else {
- ny += n;
+ ny += 1;
}
}
diff --git a/testhal/STM32/STM32F1xx/ADC/main.c b/testhal/STM32/STM32F1xx/ADC/main.c
index 32e5b82a8..fa466c2fa 100644
--- a/testhal/STM32/STM32F1xx/ADC/main.c
+++ b/testhal/STM32/STM32F1xx/ADC/main.c
@@ -30,14 +30,13 @@ static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
* ADC streaming callback.
*/
size_t nx = 0, ny = 0;
-static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
+static void adccallback(ADCDriver *adcp) {
- (void)adcp;
- if (samples2 == buffer) {
- nx += n;
+ if (adcIsBufferComplete(adcp)) {
+ nx += 1;
}
else {
- ny += n;
+ ny += 1;
}
}
diff --git a/testhal/STM32/STM32F37x/ADC/main.c b/testhal/STM32/STM32F37x/ADC/main.c
index ca5e5feb4..6beb00cdb 100644
--- a/testhal/STM32/STM32F37x/ADC/main.c
+++ b/testhal/STM32/STM32F37x/ADC/main.c
@@ -30,14 +30,13 @@ static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
* ADC streaming callback.
*/
size_t nx = 0, ny = 0;
-static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
+static void adccallback(ADCDriver *adcp) {
- (void)adcp;
- if (samples2 == buffer) {
- nx += n;
+ if (adcIsBufferComplete(adcp)) {
+ nx += 1;
}
else {
- ny += n;
+ ny += 1;
}
}
diff --git a/testhal/STM32/STM32F37x/SDADC/main.c b/testhal/STM32/STM32F37x/SDADC/main.c
index 74cb4eb50..47b4aa2a5 100644
--- a/testhal/STM32/STM32F37x/SDADC/main.c
+++ b/testhal/STM32/STM32F37x/SDADC/main.c
@@ -30,14 +30,13 @@ static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
* ADC streaming callback.
*/
size_t nx = 0, ny = 0;
-static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
+static void adccallback(ADCDriver *adcp) {
- (void)adcp;
- if (samples2 == buffer) {
- nx += n;
+ if (adcIsBufferComplete(adcp)) {
+ nx += 1;
}
else {
- ny += n;
+ ny += 1;
}
}
diff --git a/testhal/STM32/STM32F3xx/ADC/main.c b/testhal/STM32/STM32F3xx/ADC/main.c
index a6659f4e8..9305f505b 100644
--- a/testhal/STM32/STM32F3xx/ADC/main.c
+++ b/testhal/STM32/STM32F3xx/ADC/main.c
@@ -30,14 +30,13 @@ static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
* ADC streaming callback.
*/
size_t nx = 0, ny = 0;
-static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
+static void adccallback(ADCDriver *adcp) {
- (void)adcp;
- if (samples2 == buffer) {
- nx += n;
+ if (adcIsBufferComplete(adcp)) {
+ nx += 1;
}
else {
- ny += n;
+ ny += 1;
}
}
diff --git a/testhal/STM32/STM32F3xx/ADC_DUAL/main.c b/testhal/STM32/STM32F3xx/ADC_DUAL/main.c
index e8eadbeb7..6518965c8 100644
--- a/testhal/STM32/STM32F3xx/ADC_DUAL/main.c
+++ b/testhal/STM32/STM32F3xx/ADC_DUAL/main.c
@@ -30,14 +30,13 @@ static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
* ADC streaming callback.
*/
size_t nx = 0, ny = 0;
-static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
+static void adccallback(ADCDriver *adcp) {
- (void)adcp;
- if (samples2 == buffer) {
- nx += n;
+ if (adcIsBufferComplete(adcp)) {
+ nx += 1;
}
else {
- ny += n;
+ ny += 1;
}
}
diff --git a/testhal/STM32/STM32F3xx/DAC/main.c b/testhal/STM32/STM32F3xx/DAC/main.c
index aa791bf82..74491a0d0 100644
--- a/testhal/STM32/STM32F3xx/DAC/main.c
+++ b/testhal/STM32/STM32F3xx/DAC/main.c
@@ -59,16 +59,14 @@ static const dacsample_t dac_buffer[DAC_BUFFER_SIZE] = {
* DAC streaming callback.
*/
size_t nx = 0, ny = 0, nz = 0;
-static void end_cb1(DACDriver *dacp, dacsample_t *buffer, size_t n) {
-
- (void)dacp;
+static void end_cb1(DACDriver *dacp) {
nz++;
- if (dac_buffer == buffer) {
- nx += n;
+ if (dacIsBufferComplete(dacp)) {
+ nx += DAC_BUFFER_SIZE / 2;
}
else {
- ny += n;
+ ny += DAC_BUFFER_SIZE / 2;
}
if ((nz % 1000) == 0) {
diff --git a/testhal/STM32/STM32F4xx/ADC/main.c b/testhal/STM32/STM32F4xx/ADC/main.c
index 8477a0ab1..27fff6839 100644
--- a/testhal/STM32/STM32F4xx/ADC/main.c
+++ b/testhal/STM32/STM32F4xx/ADC/main.c
@@ -30,14 +30,13 @@ static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
* ADC streaming callback.
*/
size_t nx = 0, ny = 0;
-static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
+static void adccallback(ADCDriver *adcp) {
- (void)adcp;
- if (samples2 == buffer) {
- nx += n;
+ if (adcIsBufferComplete(adcp)) {
+ nx += 1;
}
else {
- ny += n;
+ ny += 1;
}
}
diff --git a/testhal/STM32/STM32F4xx/DAC/main.c b/testhal/STM32/STM32F4xx/DAC/main.c
index 4b038ea72..d4844441e 100644
--- a/testhal/STM32/STM32F4xx/DAC/main.c
+++ b/testhal/STM32/STM32F4xx/DAC/main.c
@@ -59,16 +59,14 @@ static const dacsample_t dac_buffer[DAC_BUFFER_SIZE] = {
* DAC streaming callback.
*/
size_t nx = 0, ny = 0, nz = 0;
-static void end_cb1(DACDriver *dacp, dacsample_t *buffer, size_t n) {
-
- (void)dacp;
+static void end_cb1(DACDriver *dacp) {
nz++;
- if (dac_buffer == buffer) {
- nx += n;
+ if (dacIsBufferComplete(dacp)) {
+ nx += DAC_BUFFER_SIZE / 2;
}
else {
- ny += n;
+ ny += DAC_BUFFER_SIZE / 2;
}
if ((nz % 1000) == 0) {
diff --git a/testhal/STM32/STM32F4xx/DAC_DUAL/main.c b/testhal/STM32/STM32F4xx/DAC_DUAL/main.c
index 652441efd..b39fa5913 100644
--- a/testhal/STM32/STM32F4xx/DAC_DUAL/main.c
+++ b/testhal/STM32/STM32F4xx/DAC_DUAL/main.c
@@ -59,16 +59,14 @@ static const dacsample_t dac_buffer[DAC_BUFFER_SIZE] = {
* DAC streaming callback.
*/
size_t nx = 0, ny = 0, nz = 0;
-static void end_cb1(DACDriver *dacp, dacsample_t *buffer, size_t n) {
-
- (void)dacp;
+static void end_cb1(DACDriver *dacp) {
nz++;
- if (dac_buffer == buffer) {
- nx += n;
+ if (dacIsBufferComplete(dacp)) {
+ nx += DAC_BUFFER_SIZE / 2;
}
else {
- ny += n;
+ ny += DAC_BUFFER_SIZE / 2;
}
if ((nz % 1000) == 0) {
diff --git a/testhal/STM32/STM32F4xx/I2S/main.c b/testhal/STM32/STM32F4xx/I2S/main.c
index 7eaa1b075..6a5e0a236 100644
--- a/testhal/STM32/STM32F4xx/I2S/main.c
+++ b/testhal/STM32/STM32F4xx/I2S/main.c
@@ -21,7 +21,7 @@
static uint16_t i2s_rx_buf[I2S_BUF_SIZE];
-static void i2scallback(I2SDriver *i2sp, size_t offset, size_t n);
+static void i2scallback(I2SDriver *i2sp);
static const I2SConfig i2scfg = {
NULL,
@@ -32,11 +32,14 @@ static const I2SConfig i2scfg = {
16
};
-static void i2scallback(I2SDriver *i2sp, size_t offset, size_t n) {
+static void i2scallback(I2SDriver *i2sp) {
- (void)i2sp;
- (void)offset;
- (void)n;
+ if (i2sIsBufferComplete(i2sp)) {
+ /* 2nd buffer half processing.*/
+ }
+ else {
+ /* 1st buffer half processing.*/
+ }
}
/*
diff --git a/testhal/STM32/STM32F7xx/GPT-ADC/main.c b/testhal/STM32/STM32F7xx/GPT-ADC/main.c
index 92a7da91c..d013a2354 100644
--- a/testhal/STM32/STM32F7xx/GPT-ADC/main.c
+++ b/testhal/STM32/STM32F7xx/GPT-ADC/main.c
@@ -57,7 +57,7 @@ static adcsample_t samples1[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH];
* ADC streaming callback.
*/
size_t nx = 0, ny = 0;
-static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
+static void adccallback(ADCDriver *adcp) {
#if !DMA_BUFFERS_COHERENCE
/* DMA buffer invalidation because data cache, only invalidating the
@@ -65,16 +65,14 @@ static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
Only required if the ADC buffer is placed in a cache-able area.*/
dmaBufferInvalidate(buffer,
n * adcp->grpp->num_channels * sizeof (adcsample_t));
-#else
- (void)adcp;
#endif
/* Updating counters.*/
- if (samples1 == buffer) {
- nx += n;
+ if (adcIsBufferComplete(adcp)) {
+ nx += 1;
}
else {
- ny += n;
+ ny += 1;
}
}
diff --git a/testhal/STM32/STM32L0xx/ADC/main.c b/testhal/STM32/STM32L0xx/ADC/main.c
index 0c0c8eaaf..a4c33cab2 100644
--- a/testhal/STM32/STM32L0xx/ADC/main.c
+++ b/testhal/STM32/STM32L0xx/ADC/main.c
@@ -30,14 +30,13 @@ static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
* ADC streaming callback.
*/
size_t nx = 0, ny = 0;
-static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
+static void adccallback(ADCDriver *adcp) {
- (void)adcp;
- if (samples2 == buffer) {
- nx += n;
+ if (adcIsBufferComplete(adcp)) {
+ nx += 1;
}
else {
- ny += n;
+ ny += 1;
}
}
diff --git a/testhal/STM32/STM32L1xx/ADC/main.c b/testhal/STM32/STM32L1xx/ADC/main.c
index 79305dafc..f01da1d3c 100644
--- a/testhal/STM32/STM32L1xx/ADC/main.c
+++ b/testhal/STM32/STM32L1xx/ADC/main.c
@@ -30,14 +30,13 @@ static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
* ADC streaming callback.
*/
size_t nx = 0, ny = 0;
-static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
+static void adccallback(ADCDriver *adcp) {
- (void)adcp;
- if (samples2 == buffer) {
- nx += n;
+ if (adcIsBufferComplete(adcp)) {
+ nx += 1;
}
else {
- ny += n;
+ ny += 1;
}
}
diff --git a/testhal/STM32/STM32L4xx/ADC/Makefile b/testhal/STM32/STM32L4xx/ADC/Makefile
index 402c1ce74..8c74815fd 100644
--- a/testhal/STM32/STM32L4xx/ADC/Makefile
+++ b/testhal/STM32/STM32L4xx/ADC/Makefile
@@ -5,7 +5,7 @@
# Compiler options here.
ifeq ($(USE_OPT),)
- USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
diff --git a/testhal/STM32/STM32L4xx/ADC/debug/STM32L4xx-ADC (OpenOCD, Flash and Run).launch b/testhal/STM32/STM32L4xx/ADC/debug/STM32L4xx-ADC (OpenOCD, Flash and Run).launch
index 89c0ca557..f752b6269 100644
--- a/testhal/STM32/STM32L4xx/ADC/debug/STM32L4xx-ADC (OpenOCD, Flash and Run).launch
+++ b/testhal/STM32/STM32L4xx/ADC/debug/STM32L4xx-ADC (OpenOCD, Flash and Run).launch
@@ -1,52 +1,52 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType">
-<stringAttribute key="bad_container_name" value="\STM32L4xx-ADC\debug"/>
-<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="1"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="true"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#13;&#10;"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
-<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
-<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
-<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
-<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/>
-<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
-<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
-<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
-<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
-<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
-<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
-<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList/&gt;"/>
-<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;globalVariableList/&gt;&#13;&#10;"/>
-<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList/&gt;&#13;&#10;"/>
-<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
-<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32L4xx-ADC"/>
-<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
-<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="0.1093754934"/>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/STM32L4xx-ADC"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="4"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
-<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
-</listAttribute>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType">
+<stringAttribute key="bad_container_name" value="\STM32L4xx-ADC\debug"/>
+<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="1"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#13;&#10;"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
+<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
+<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
+<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
+<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/>
+<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
+<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
+<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
+<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
+<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
+<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList/&gt;"/>
+<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/>
+<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList/&gt;&#10;"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32L4xx-ADC"/>
+<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
+<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="0.1093754934"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/STM32L4xx-ADC"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+</listAttribute>
+</launchConfiguration>
diff --git a/testhal/STM32/STM32L4xx/ADC/main.c b/testhal/STM32/STM32L4xx/ADC/main.c
index 95b211f58..e86cefa2a 100644
--- a/testhal/STM32/STM32L4xx/ADC/main.c
+++ b/testhal/STM32/STM32L4xx/ADC/main.c
@@ -30,14 +30,13 @@ static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
* ADC streaming callback.
*/
size_t nx = 0, ny = 0;
-static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
+static void adccallback(ADCDriver *adcp) {
- (void)adcp;
- if (samples2 == buffer) {
- nx += n;
+ if (adcIsBufferComplete(adcp)) {
+ nx += 1;
}
else {
- ny += n;
+ ny += 1;
}
}
@@ -161,7 +160,7 @@ int main(void) {
* Normal main() thread activity, in this demo it does nothing.
*/
while (true) {
- if (palReadPad(GPIOC, GPIOC_BUTTON)) {
+ if (!palReadPad(GPIOC, GPIOC_BUTTON)) {
adcStopConversion(&ADCD1);
}
chThdSleepMilliseconds(500);
diff --git a/testhal/STM32/multi/DAC/main.c b/testhal/STM32/multi/DAC/main.c
index e8643c183..08786f002 100644
--- a/testhal/STM32/multi/DAC/main.c
+++ b/testhal/STM32/multi/DAC/main.c
@@ -61,16 +61,14 @@ static const dacsample_t dac_buffer[DAC_BUFFER_SIZE] = {
* DAC streaming callback.
*/
size_t nx = 0, ny = 0, nz = 0;
-static void end_cb1(DACDriver *dacp, dacsample_t *buffer, size_t n) {
-
- (void)dacp;
+static void end_cb1(DACDriver *dacp) {
nz++;
- if (dac_buffer == buffer) {
- nx += n;
+ if (dacIsBufferComplete(dacp)) {
+ nx += DAC_BUFFER_SIZE / 2;
}
else {
- ny += n;
+ ny += DAC_BUFFER_SIZE / 2;
}
if ((nz % 1000) == 0) {
diff --git a/testhal/STM32/multi/SPI/main.c b/testhal/STM32/multi/SPI/main.c
index aa8d9bb33..96e2ee154 100755
--- a/testhal/STM32/multi/SPI/main.c
+++ b/testhal/STM32/multi/SPI/main.c
@@ -32,7 +32,7 @@ CC_ALIGN(32) static uint8_t rxbuf[512];
*/
void spi_circular_cb(SPIDriver *spip) {
- if(spip->state == SPI_COMPLETE) {
+ if (spiIsBufferComplete(spip)) {
/* 2nd half.*/
palWriteLine(PORTAB_LINE_LED1, PORTAB_LED_OFF);
}