Chibios Usb Serial Example

Detailed Description. Serial over USB Driver. This module implements an USB Communication Device Class (CDC) as a normal serial communication port. ChibiOS/RT free embedded RTOS. I have just tested USB CDC example with my STM32F4 Discovery and it work fine, but I need in fact a USB Dual CDC to have 2 Virtual Serial Port, 1 for commands with a shell and a second for data received. Does anyone have already done that?

ChibiOS/RT
Written inC, Assembly language
OS familyReal-time operating systems
Working stateStable
Source modelOpen source
Latest release19.1.3 / July 14, 2019; 6 months ago
Repository
PlatformsIntel 80386, ARM7, ARM9, ARM Cortex-M0, ARM Cortex-M3, ARM Cortex-M4, PowerPC, e200z, Atmel AVR, TI MSP430, STM8, Freescale Coldfire, Renesas H8S
Kernel typeMicrokernel
LicenseGPL3 or proprietary
Official websitewww.chibios.org

ChibiOS/RT is a compact and fast[1]real-time operating system supporting multiple architectures and released under the GPL3 license. It is developed by Giovanni Di Sirio.

Metrics[edit]

Example

ChibiOS/RT is designed for embedded applications on 8, 16 and 32 bit microcontrollers; size and execution efficiency are the main project goals.[2] As reference, the kernel size can range from a minimum of 1.2 Kib up to a maximum of 5.5 KiB with all the subsystems activated on a STM32 Cortex-M3 processor. The kernel is capable of over 220,000 created/terminated threads per second and is able to perform a context switch in 1.2 microseconds on an STM32 @ 72 MHz. Similar metrics for all the supported platforms are included in the source distribution as test reports.

Features[edit]

The ChibiOS/RT microkernel supports:

  • Preemptive multithreading[3]
  • 128 priority levels
  • Round-robin scheduling for threads at the same priority level
  • Software timers
  • Counting semaphores
  • Mutexes with support for the priority inheritance algorithm
  • Synchronous and asynchronous Messages
  • Event flags and handlers
  • Synchronous and asynchronous I/O with timeout capability
  • Thread-safe memory heap and memory pool allocators.
  • Hardware Abstraction Layer with support for ADC, CAN, GPT (general-purpose timer), EXT, I²C, ICU, MAC, MMC/SD, PAL, PWM, RTC, SDC, Serial, SPI, and USB drivers.
  • Support for the LwIP and uIP TCP/IP stacks.
  • Support for the FatFs file system library.

All system objects, such as threads, semaphores, timers, etc., can be created and deleted at runtime. There is no upper limit except for the available memory.In order to increase system reliability, the kernel architecture is entirely static, a memory allocator is not required (but is available as an option), and there are no data structures with upper size limits like tables or arrays. The system APIs are designed to not have error conditions such as error codes or exceptions.

The RTOS is designed for applications on embedded devices and includes demo applications for various microcontrollers:

  • ST STM32F1xx, STM32F2xx, STM32F3xx, STM32F4xx, STM32L1xx, STM32F0xx
  • ST STM8S208x, STM8S105x, STM8L152x
  • ST/Freescale SPC56x / MPC56xx
  • NXP LPC11xx, LPC11Uxx, LPC13xx
  • NXP LPC2148
  • Atmel AT91SAM7S, AT91SAM7X
  • Atmel Mega AVR
  • TI MSP430x1611
  • TI TM4C123G and TM4C1294
  • Microchip PIC32MX

Contributed ports are also available for the Coldfire and H8S families.[4]

ChibiOS/RT has also been ported to the Raspberry Pi[5] and the following device drivers have been implemented: Port (GPIO), Serial, GPT (General-Purpose Timer), I2C, SPI and PWM.

It is also possible to run the kernel in a Win32process in a software I/O emulation mode, allowing easy application development without the need for physical hardware. An example is included for MinGWcompiler. Safeassign plagiarism software for students.

ChibiOS/RT is supported by popular embedded TLS/SSL libraries such as wolfSSL.

uGFX[edit]

ChibiOS/RT is fully supported by the GUI toolkit µGFX. Tamil cut songs download mp3. µGFX was formerly known as ChibiOS/GFX.

See also[edit]

References[edit]

  1. ^RTOS performance data on emb4fun.deArchived 2013-01-11 at Archive.today
  2. ^ChibiOS/RT statistics on ohloh.net
  3. ^A detailed explanation of multithreading in ChibiOS/RT
  4. ^Additional supported architectures on emb4fun.deArchived 2013-01-11 at Archive.today
  5. ^'ChibiOS/RT on the Raspberry Pi'.

External links[edit]

Retrieved from 'https://en.wikipedia.org/w/index.php?title=ChibiOS/RT&oldid=915605188'
Permalink

Join GitHub today

GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Sign up
Branch:master
Find file Copy path
Fetching contributors…
/*
* A Simple USART example for printing on the serial port
* 115200 Baud - 8N1
* PC10 - TX (transmits data from uC).
* PC11 - RX
*/
#include'ch.h'
#include'hal.h'
#include'chprintf.h'
#defineUSART_CR1_9BIT_WORD (1 << 12) /* CR1 9 bit word */
#defineUSART_CR1_PARITY_SET (1 << 10) /* CR1 parity bit enable */
#defineUSART_CR1_EVEN_PARITY (0 << 9) /* CR1 even parity */
#definePrintS2(x) SendString(&SD3, x); /* for example 4 */
staticvoidSendString(SerialDriver *sdp, constchar *string); /* for example 3 */
staticvoidprint(char *p);
staticvoidprintln(char *p);
staticvoidprintn(uint32_t n);
static SerialConfig sd3cfg = {
115200, /* 115200 baud rate */
USART_CR1_9BIT_WORD USART_CR1_PARITY_SET USART_CR1_EVEN_PARITY,
USART_CR2_STOP1_BITS USART_CR2_LINEN,
0
};
intmain(void) {
halInit();
chSysInit();
/*
* Activates the serial driver 3 using the driver sd3cfg configuration.
* PC10(TX) and PC11(RX) are routed to USART3.
* PAL_MODE_ALTERNATE is the value that you pass from Table 9. Alternate function mapping
* in DM00037051 - STM32F405xx/STM32F407xx Datasheet
*/
sdStart(&SD3, &sd3cfg);
palSetPadMode(GPIOC, 10, PAL_MODE_ALTERNATE(7));
palSetPadMode(GPIOC, 11, PAL_MODE_ALTERNATE(7));
while (TRUE){
staticuint8_t temp = 0;
if (palReadPad(GPIOA, GPIOA_BUTTON))
sdWrite(&SD3, (uint8_t *)'Button Pressed!rn', 17);
sdWrite(&SD3, (uint8_t *)'Example: 1rn', 12);
chprintf((BaseSequentialStream *)&SD3, 'Example: %drn', 2);
SendString(&SD3, 'Example: 3rn');
PrintS2('Example: 4rn');
print('Example: 5rn');
println('Example: 6');
temp = temp + 1;
print('Counter: '); printn(temp); print('rn++++++++++++rn');
if (temp 255) temp = 0;
chThdSleepMilliseconds(250); /* Sleep the processor for 250 milliseconds */
}
}
staticvoidprint(char *p) {
while (*p) chSequentialStreamPut(&SD3, *p++);
}
staticvoidprintln(char *p) {
while (*p) chSequentialStreamPut(&SD3, *p++);
chSequentialStreamWrite(&SD3, (uint8_t *)'rn', 2);
}
staticvoidprintn(uint32_t n) {
char buf[16], *p;
if (!n) chSequentialStreamPut(&SD3, '0');
else {
p = buf;
while (n)
*p++ = (n % 10) + '0', n /= 10;
while (p > buf)
chSequentialStreamPut(&SD3, *--p);
}
}
staticvoidSendString(SerialDriver *sdp, constchar *string){
uint8_t i;
for (i=0; string[i]!='0'; i++)
sdPut(sdp, string[i]);
}
  • Copy lines
  • Copy permalink