Skip to content

rbudai98/chibiOS-drivers

Repository files navigation

ChibiOS and no-OS drivers

Interfacing solution between ChibiOS Hardware Abstraction Layer/Real Time Operating System and No-OS driver stack

Table of contents

  1. Content
  2. Usage
  3. Pre-requirements
    1. Sources and editor
    2. For testing
  4. Projects
    1. Open project
    2. RT-STM32F469I-EVAL-SDP-CK1Z-GPIO
    3. RT-STM32F469I-EVAL-SDP-CK1Z-BUTTON
    4. RT-STM32F469I-EVAL-SDP-CK1Z-ADXL355
    5. RT-STM32F469I-EVAL-SDP-CK1Z-I2C

Usage:

  1. Install ChibiOS: https://www.chibios.org/dokuwiki/doku.php
  2. After extracting the OS, in the workspace add the directory examples and modify in the main Makefile the path towards os [$(CHIBIOS)] and the path toward no-os repository [$(NOOS)]

Pre-requirements

Sources and editor

git clone https://github.com/analogdevicesinc/no-OS.git
  • Download and extract the provided examples from https://github.com/rbudai98/chibiOS-drivers (Code -> Download ZIP) and copy the project folders into C:/ChibiOS/
    Alternatively one can clone the repository directly into C:/ChibiOS/ with command
git clone https://github.com/rbudai98/chibiOS-drivers.git

For Testing

Projects

Opening Project:

For source code editing and flashing the chibios studio framework is used. One can import any project at Files -> Open Project from File System -> Select workdir and project -> Finish

Import steps

  • Equipment:

  • Wiring diagram: WIRING_SDPK1_BUTTON

  • API:

Chibios provides a initalization structure for GPIO pins with properties (PORT, PAD and MODE):

struct chibios_gpio_init_param chibios_gpio_extra_ip = {
  .port = GPIOB,
  .pad = 15U,
  .mode = PAL_MODE_OUTPUT_OPENDRAIN,
};

This init param has to be set properly first. After this it is linked to no_os_gpio_init_param structure via a pointer, found within the no_os api:

struct no_os_gpio_init_param chibios_GPIO = {
  .platform_ops = &chibios_gpio_ops,
  .extra = &chibios_gpio_extra_ip,
};

In order to initialize the gpio pin:

no_os_gpio_get(&gpio_desc, &chibios_GPIO);

After initialization the GPIO pin has been assigned the proper values and is ready to be used. To alternate the led:

no_os_gpio_set_value(gpio_desc, PAL_LOW);
chThdSleepMilliseconds(1000);
no_os_gpio_set_value(gpio_desc, PAL_HIGH);
chThdSleepMilliseconds(1000);
  • Equipment:

  • Wiring diagram: WIRING_SDPK1_BUTTON

  • API:

Chibios provides a initalization structure for GPIO pins with properties (PORT, PAD and MODE):

struct chibios_gpio_init_param chibios_gpio_extra_ip_5 = {
  .port = GPIOA,
  .pad = 1U,
  .mode = PAL_MODE_OUTPUT_PUSHPULL,
};

This init param has to be set properly first. After this it is linked to no_os_gpio_init_param structure via a pointer, found within the no_os api:

struct no_os_gpio_init_param chibios_GPIO_5 = {
  .platform_ops = &chibios_gpio_ops,
  .extra = &chibios_gpio_extra_ip_5,
};

In order to initialize the gpio pin:

no_os_gpio_get(&gpio_desc_5, &chibios_GPIO_5);

After initialization the GPIO pin has been assigned the proper values and is ready to be used. To read it's value an extra variable is declared, as follows:

uint8_t tmp;
no_os_gpio_get_value(gpio_desc_5, &tmp);

The serial output looks like the following (Baudrate: 38400) : serial_output

Chibios offers a the SPI initialization parameter:

SPIConfig spicfg = {
  .circular         = false,
  .slave            = false,
  .data_cb          = NULL,
  .error_cb         = NULL,
  .ssline           = LINE_ARD_D10,
  .cr1              = SPI_CR1_BR_2,
  .cr2              = 0
};

The previous configuration is assigned to the no-os initialization parameter structure:

struct chibios_spi_init_param chibios_spi_extra_ip  = {
   .hspi=&SPID1,
   .spicfg=&spicfg,
};

This configuration is later linked to the No-Os API through the no_os_spi_init_param-> extra:

struct no_os_spi_init_param adxl355_spi_ip = {
    .platform_ops = &chibios_spi_ops,
    .extra = &chibios_spi_extra_ip,
};

Later these setting are assigned to the device descriptor in the following line:

  adxl355_ip.comm_init.spi_init = adxl355_spi_ip;

Before using the device drive we have to assign the appropriate variables for the device's initialization parameter:

struct adxl355_init_param adxl355_ip = {
    .comm_type = ADXL355_SPI_COMM,
    .dev_type = ID_ADXL355,
};

After having the appropriate settings, we can initialize the driver, read-write registers and obtain data:

  ret = adxl355_init(&adxl355_desc, adxl355_ip);
  if (ret)
      goto error;
  ret = adxl355_soft_reset(adxl355_desc);
  if (ret)
      goto error;
  ret = adxl355_set_odr_lpf(adxl355_desc, ADXL355_ODR_3_906HZ);
  if (ret)
      goto error;
  ret = adxl355_set_op_mode(adxl355_desc, ADXL355_MEAS_TEMP_ON_DRDY_OFF);
  if (ret)
      goto error;

  sdStart(&SD5, NULL);

  while(1) {
      ret = adxl355_get_xyz(adxl355_desc,&x[0], &y[0], &z[0]);
  }
  
error:
  return 0;

The serial output looks like the following (Baudrate: 38400) : serial_output

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published