I am new to RTEMS and I want to write a very simple character device for it but when I search in internet I can't find anything.
I can write character device for linux but doesn't have any experience in RTEMS.
I want to write a character device having 3 function: init(), exit() , read().
and when i call read just return a string.
Is there any reference to give me a hint to write this simple device driver?
This maybe depends a bit what you mean by "simple character device". I assume that you want something that is accessible via a device interface (similar to the Linux character devices).
In RTEMS there are some frameworks for I2C, SPI, serial ports, and some more simple interfaces. Quite a bit of drivers is pulled in from FreeBSD via libbsd and therefore uses the FreeBSD interface. Hardware that doesn't fit one of the frameworks uses a self defined interface most of the time. That can also be a file like interface.
If you want to use a file like interface you want to take a look at IMFS_make_generic_node. You can take a look at the I2C driver for a fully working example: https://git.rtems.org/rtems/tree/cpukit/dev/i2c/i2c-dev.c?id=94481cedc4165f6a49ef5287098251740922fee1#n147
A bit of a more minimal example could look like follows: Note that I write the following more or less from my head so there can be quite some typos and there are quite sure missing headers:
Calling my_Initialize should give you a "/dev/my_dev" where you can read any amount of 42 that you want.