I have a problem with a function, sdStart () on board SPC560P.
I am using the test application ADC and would like to use the serial port for output (because I'm running a sensor).
I have a problem with a function, sdStart () on board SPC560P.
I am using the test application ADC and would like to use the serial port to have a
Output Output (because I'm running a sensor).
I then modified the code of the test program by adding the function of the ADC sdStart (& SD1, NULL). The compiler me an error: SD1 undeclared. I also added the libraries
#include "serial.h"
#include "serial_lld.h"
This is my code
Code: Select all
/*
SPC5 HAL - Copyright (C) 2013 STMicroelectronics
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
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.
*/
/* Inclusion of the main header files of all the imported components in the
order specified in the application wizard. The file is generated
automatically.*/
#include "components.h"
#include "adc_lld_cfg.h"
#include "serial.h"
#include "serial_lld.h"
/*
* Buffers used for the ADC conversions, note, the constants are defined
* in adc_lld_cfg.h and are generated automatically.
*/
static adcsample_t samples1[ADC0_GROUP_CFG0_NUM_CHANNELS *
ADC0_GROUP_CFG0_BUF_DEPTH];
static adcsample_t samples2[ADC1_GROUP_CFG0_NUM_CHANNELS *
ADC1_GROUP_CFG0_BUF_DEPTH];
/*
* ADC streaming callback, the name is defined in the ADC graphic
* configuration.
*/
size_t nx = 0, ny = 0;
void adc_conversion_callback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
(void)adcp;
if (samples2 == buffer) {
nx += n;
}
else {
ny += n;
}
}
/*
* ADC error callback, the name is defined in the ADC graphic
* configuration.
*/
uint32_t errore = 30;
void adc_error_callback(ADCDriver *adcp, adcerror_t err) {
(void)adcp;
errore = err;
palClearPad(PORT_A, Led_D11);
osalSysHalt("ADC failure");
}
/*
* Application entry point.
*/
int main(void) {
/* Initialization of all the imported components in the order specified in
the application wizard. The function is generated automatically.*/
componentsInit();
sdStart(&SD1, NULL);
palSetPad(PORT_A,Led_D11);
/* Starts the ADCD1, ADCD2 drivers.*/
adcStart(&ADCD1, NULL);
adcStart(&ADCD2, NULL);
/* Linear conversion.*/
adcConvert(&ADCD1, &adc0_group_cfg0,
samples1, ADC0_GROUP_CFG0_BUF_DEPTH);
osalThreadSleepMilliseconds(1000);
/* Starts an ADC continuous conversion.*/
adcStartConversion(&ADCD2, &adc1_group_cfg0,
samples2, ADC1_GROUP_CFG0_BUF_DEPTH);
/* Normal main() thread activity, once the button is pressed the background
ADC conversion is stopped.*/
while (TRUE) {
osalThreadSleepMilliseconds(100);
palTogglePad(PORT_A,Led_D12);
osalThreadSleepMilliseconds(100);
palTogglePad(PORT_A,Led_D12);
}
}
But it does not work. Does anyone have an idea?
Thanks.
Best regards
Gianluca