Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to interact directly with hardware?

I know this has to be possible because there are programs that can control hardware (for example the LED lights on my keyboard, or the CPU fan) what I'd like to know is what I would have to do to interact with this hardware.
To be more specific, I want to (as a learning project) control when my laptop's (Sony Vaio Flip SVF14N13CXB) backlit keyboard lights up. I would like to find out if each letter/segment's LED can be controlled individually, and if it can it'd be cool to do some coding that would light up just the area being pressed (for example if each key has its own LED, when I press the "W" key, just the "W" key's LED would light up). I am mainly doing this as a learning project, but gave examples so you can know what I want. I hope you understand what I'm asking. Thanks.

like image 337
Skylar Grant Avatar asked Oct 20 '22 02:10

Skylar Grant


1 Answers

I don't know what is your exact purpose for controlling different components of Hardware. I will recommend you go with Language C and Assembly Language. There are reasons for recommending C are:

  1. It runs directly on the Hardware abstraction layer and gives most of the controls of the hardware.

  2. Most of the Hardware Manufacture Drivers are made in C as it gives them more flexibility.

  3. It is portable to Multiple O/S and they have change little code according to Hardware Requirements.

I would give a snapshot about things you know about controlling Hardware but it requires great cautions and skills. As doing wrongly some time damages the Hardware too.

How to control them?

Every device is controlled by writing and reading its registers. Most of the time a device has several registers, and they are accessed at consecutive addresses, either in the memory address space or in the I/O address space.

While some CPU manufacturers implement a single address space in their chips, others decided that peripheral devices are different from memory and, therefore, deserve a separate address space. I/O ports are the means by which drivers communicate with many devices, at least part of the time. I/O instructions are, by their nature, highly processor dependent. Because they work with the details of how the processor handles moving data in and out, it is very hard to hide the differences between systems.

I/O memory is simply a region of RAM-like locations that the device makes available to the processor over the bus. This memory can be used for a number of purposes, such as holding video data or Ethernet packets, as well as implementing device registers that behave just like I/O ports (i.e., they have side effects associated with reading and writing them).

The way to access I/O memory depends on the computer architecture, bus, and device being used, although the principles are the same everywhere.

like image 159
Vineet1982 Avatar answered Oct 23 '22 00:10

Vineet1982