5

what types of codes are written in CMSIS files and peripheral drivers file. How can I distinguish them? any example would be more helpful. Thank you.

istiaq2379
  • 113
  • 3
  • 13

2 Answers2

5

"CMSIS" is the Cortex Microcontroller Software Interface Standard. It's an ARM standard, so the code should be more or less portable between Cortex implementations.

Peripheral libraries generally are more vendor-specific, since there's no standard for how two different vendors will implement e.g. a timer or a UART block.

At least, that's my basic understanding from working (mostly) with ARMs in the STM32 family. However, I notice on that CMSIS page that the scope for CMSIS is actually larger:

CMSIS-Driver: defines generic peripheral driver interfaces for middleware making it reusable across supported devices. The API is RTOS independent and connects microcontroller peripherals with middleware that implements for example communication stacks, file systems, or graphic user interfaces.

That sounds like it'd do things that I associate with vendor-specific code, but perhaps not all vendors actually use CMSIS-Driver yet.

UPDATE: On the STM32:s I've worked with, GPIO is managed using only ST's peripheral library.

It's pretty easy, really:

  1. Use RCC_AHB1PeriphClockCmd() to enable the GPIO peripheral's clock. There are many clocks so make sure you do it right. I think all the GPIO is on AHB1.
  2. Initialize a variable of type GPIO_InitTypeDef by calling GPIO_StructInit() on it to get the defaults.
  3. Set the settings you really want in your GPIO_InitTypeDef, overriding the defaults as needed.
  4. Call GPIO_Init() on the proper port, also passing it the GPIO_InitTypeDef with your actual settings. This will poke registers in the peripheral.
  5. Use calls like GPIO_SetBits(), GPIO_ReadInputDataBit() et cetera to actually use the GPIO pin.
unwind
  • 391,730
  • 64
  • 469
  • 606
  • actually I also thought something like this...but actually for me it seems both are same. But they aren't. suitable GPIO example would be nice to know. I just started STM32 1 week before. So it would be helpful. – istiaq2379 Sep 05 '14 at 09:34
  • For Stm32F10x: `RCC_APB2Periph…` but for F2xx and F4xx: `RCC_AHB1Periph…` and IMHO for F30x: `RCC_AHBPeriph…`. – Joe Sep 16 '14 at 22:40
0

CMSIS code are written for the ARM controller for different vendor like NXP (LPC series etc.) STM (STM32f4, stm32F1 ) basically the controller which has ARM architecture. this is portable software. this coding language is C/C++ most of the time but in some file assembly language is used. generally the assembly language are used in startup files.

In the peripheral driver the code are written in c/c++ language. peripheral driver are used to communications purposes.

I'm currently working on the LPC18xx controller, using the CMSIS driver, the CMSIS driver has code for all the peripherals, you can use the driver directly to implement your application

for example : if you want to read the data from the sensor connected via I2C. you can directly used the I2C Cmsis driver to implement application. only thing you need to know this the hardware address to the sensor.

similarly you can use SPI driver, CMSIS also provide RTOS driver.