Easylab board and new dsPIC ERIKA Enterprise Driver API

From ErikaWiki

Jump to: navigation, search

Contents

Introduction

During the development of Erika support for easylab some new API have created and other ones have been updated. Follow an overview of these changes, but to be sure that the information of this page are updated double check the code.

Easylab Board API

The EasyLab board is fully supported by Erika Rtos. This chapter describes the API support done in Erika Enterprise for the Evidence EasyLab Board. To configure the usage of the EasyLab Board, the user has to specify an appropriate BOARD_DATA in OIL file , as in the following example:

...
BOARD_DATA = EE_EASYLAB {
...
}
...

this OIL element enable the inclusion of pkg/board/ee_easylab/inc/ee_board.h as board header.


System LED

The Microstic Guest board has a system LED attached to a GPIO pin of the microcontroller. To use the system LED, the developer should specify the USELEDS attribute as TRUE, as in the following example:

...
BOARD_DATA = EE_EASYLAB {
  USELEDS = TRUE;
  ...
}
...

The following paragraphs will describe the functions available to control the easyLab System LED.

  • void EE_sys_led_init(void);
    Description: Initialize the system LED (the one on microstick). The LED starts turned off.
  • void EE_sys_led_on(void);
    Description: The function turns on the system LED (the one on microstick).
  • void EE_led_sys_off(void);
    Description: The function turns off the system LED (the one on microstick).

Board LEDs

The EasyLab includes 8 red LEDs. To use the board LEDs the developer have to specify the USELEDS attribute as TRUE, as in the following example (same OIL configuration of the System LED):

...
BOARD_DATA = EE_EASYLAB {
  USELEDS = TRUE;
  ...
}
...

The API for board LEDS control are the follow:

  • void EE_leds_init(void);
    Description: Initialize all LEDS present on the board. The LEDs starts turned off.
  • void EE_leds_enable(void);
    Description: Turn on all the LEDs present on the board (system LED too).
  • void EE_leds_disable(void);
    Description: Turn off all the LEDs present on the board (system LED too).
  • void EE_ledx_init(void); (x=1,...,8)
    Description: Initialize the LEDx present on the board (x=1,...,8). The LED starts turned off.
  • void EE_ledx_on(void); (x=1,...,8)
    Description: Turn on the LEDx present on the board (x=1,...,8).
  • void EE_led1_off(void); (x=1,...,8)
    Description: Turn off the LEDx present on the board (x=1,...,8).
  • void EE_led1_toggle(void); (x=1,...,8)
    Description: Toggle the LEDx present on the board (x=1,...,8).

Digital Pin I/O

The same pins connected to board LEDS can be used how general Digital Pin I/O. These pins are exported on board connectors.

For their use on the board the developer have to specify the USE_DIO attribute as TRUE, as in the following example (same OIL configuration of the DIO):

...
BOARD_DATA = EE_EASYLAB {
  USEDIO = TRUE;
  ...
}
...

The API than uses the digital pins I/O (DIO) are the follow:

  • void EE_diox_configure(EE_BIT in); (x=1,...,8)
    Description: Initialize the pinx (x=1,...,8). If the in parameter is 0 (zero) the pin is output while 1 is input.
  • void EE_diox_write(EE_BIT bit); (x=1,...,8)
    Description: If the parameter in=1 the output pin is 1 logic, while if the parameter in=0 the output pin is 0 logic.
  • int EE_BIT EE_diox_read(void); (x=1,...,8)
    Description: The API return the logic value on pinx when it is configured as input.

Buzzer

On the EasyLab board is present a simple piezo buzzer. When the users wants use it in a his project, he has to write, in the OIL file, something like this:

...
BOARD_DATA = EE_EASYLAB {
  USEBUZZER = TRUE;
  ...
}
...

The API are the follow:

  • void EE_buzzer_start(EE_UINT16 freq);
    Description: Start on the buzzer. The parameter freq is the frequency value and it's value is from 100 to 48000 Hz.
  • void EE_buzzer_stop(void);
    Description: Turn off the buzzer sound.

ADC Channels

The EasyLab board has 4 input analog to digital converter (ADCx). If an application uses the ADC functionality in necessary modified the OIL file adding the option USEADC:

...
BOARD_DATA = EE_EASYLAB {
  USEADC = TRUE;
  ...
}
...

The ADC's API are the follow:

  • EE_INT8 EE_easylab_adc_init_ch(EE_AdcChId adc_ch_id, EE_Adc_VoltageRef volt_ref, EE_Adc_BitResolution bit_res);
    Description: Initialize an specific ADC channel. The parameter can be used are the follow:
    • adc_ch_id: Is the ADC channel, the value can be:
      • EE_ADC_AN1
      • EE_ADC_AN2
      • EE_ADC_AN3
      • EE_ADC_AN4
    • volt_ref : Is the Ref for ADC conversion. At this parameter can be assigned the follow value:
      • EE_ADC_VDD_VSS
      • EE_ADC_VREFh_VSS
      • EE_ADC_VDD_VREFl
      • EE_ADC_VREFh_VREFl
    • bit_res : Is the resolution of the ADC.
      • EE_ADC_10_BIT
      • EE_ADC_12_BIT
    • return value: 0 if no errors happened. Otherwise appropriate error value (negative value).
  • EE_INT8 EE_easylab_adc_get_ch_uint(EE_AdcChId adc_ch_id, EE_UINT16 * value );
    Description: Acquire analog value on specific input.
    • adc_ch_id: Channel's ID to acquire.
      • EE_ADC_AN1
      • EE_ADC_AN2
      • EE_ADC_AN3
      • EE_ADC_AN4
    • *value: return value conversion pointer.
    • return value: 0 if no errors happened. Otherwise appropriate error value (negative value).
  • EE_INT8 EE_INT8 EE_easylab_adc_start(void):
    Description: Start ADC sampling.
    • return value: 0 if no errors happened. Otherwise appropriate error value (negative value).
  • EE_INT8 EE_easylab_adc_stop(void):
    Description: Stop ADC sampling.
    • return value: 0 if no errors happened. Otherwise appropriate error value (negative value).

PWM Channels

The EasyLab board has 4 independent and configurable pwm output (PWM1, PWM2, PWM3 and PWM4). These outputs can work also how two both pwm configuration (PWM12, PWM1 together PWM2 and PWM34, PWM3 with PWM4). In the OIL file need to use the flag USEPWM:

...
BOARD_DATA = EE_EASYLAB {
  USEPWM = TRUE;
  ...
}
...

The PWM's API are the follow:

  • EE_INT16 EE_easylab_pwm_init(EE_UINT8 pwm_pin, EE_UINT32 pwm_freq);
    Description: Initialize an specific PWM channel. The parameter can be used are the follow:
    • pwm_pin: Is the PWM channel, its values can be:
      • EE_EASYLAB_PWM1
      • EE_EASYLAB_PWM2
      • EE_EASYLAB_PWM3
      • EE_EASYLAB_PWM4
      • EE_EASYLAB_PWM12
      • EE_EASYLAB_PWM34
    • pwm_freq: pwm frequency
    • return value: 0 if no errors happened. Otherwise appropriate error value (negative value).
  • EE_INT16 EE_easylab_pwm_close(EE_UINT8 pwm_pin);
    Description: Close the specific PWM channel passed as parameter.
    • pwm_pin: Is the PWM channel, its values can be:
      • EE_EASYLAB_PWM1
      • EE_EASYLAB_PWM2
      • EE_EASYLAB_PWM3
      • EE_EASYLAB_PWM4
      • EE_EASYLAB_PWM12
      • EE_EASYLAB_PWM34
    • return value: 0 if no errors happened. Otherwise appropriate error value (negative value).
  • EE_INT16 EE_easylab_pwm_set_duty(EE_UINT8 pwm_pin, EE_UINT16 duty);
    Description: Set the duty-cycle at specific PWM channel passed as parameter.
    • pwm_pin: Is the PWM channel, its values can be:
      • EE_EASYLAB_PWM1
      • EE_EASYLAB_PWM2
      • EE_EASYLAB_PWM3
      • EE_EASYLAB_PWM4
      • EE_EASYLAB_PWM12
      • EE_EASYLAB_PWM34
    • duty: duty-cycle
    • return value: 0 if no errors happened. Otherwise appropriate error value (negative value).
Personal tools