[SOLVED] Problem libraries

ChibiOS public support forum for topics related to the STMicroelectronics SPC56x family of automotive micro-controllers.
Post Reply
GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm

[SOLVED] Problem libraries

Post by GianlucaLaManna »

Hi,
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
Last edited by GianlucaLaManna on Fri Apr 03, 2015 4:52 pm, edited 1 time in total.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problem libraries

Post by Giovanni »

Hi,

You need to enable the serial driver in the "portable HAL" component and the LinFLEX1 in the "drivers component". All drivers and peripherals are disabled by default.

Giovanni
GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm

Re: Problem libraries

Post by GianlucaLaManna »

Ok. I activated the serial connection in the file header halconf.h TRUE putting the line:

Code: Select all

 #define HAL_USE_SERIAL              TRUE 

Then I put in the file serial_lld.h TRUE line:

Code: Select all

SPC5_SERIAL_USE_LINFLEX1            TRUE

The compiler says: SERIAL driver activated but no LINFlex peripheral assigned.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problem libraries

Post by Giovanni »

This is done using the configuration tool, you shouldn't edit the configuration files manually.

Giovanni
GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm

Re: Problem libraries

Post by GianlucaLaManna »

Ok. Sorry for my incompetence :oops: . I used the graphical tool. I checked the serial port and set LINFLEX1 of "serial". But it still does not work.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problem libraries

Post by Giovanni »

My error, SD1 is LinFlex0.

Giovanni
GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm

Re: Problem libraries

Post by GianlucaLaManna »

Yes. I had seen, as I compared the two files looking at the file that uses the serial port. This does not solve the problem. :(
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problem libraries

Post by Giovanni »

After configuring, you have to "generate" for the changes to have effect.

Giovanni
GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm

Re: Problem libraries

Post by GianlucaLaManna »

Yeees. It works. Thank you so much. :mrgreen:

Gianluca.
Post Reply