Search code examples
usbdriverapi-design

Is it possible to start working on an API for a hardware device before having the driver


I'm new to the development process in this domain, so my question might not seem very logical.

I'm working on a project to produce a new USB device. Let's assume that this device is a webcam. One of the main features of this device is that it should have a very smart API so that programmers can get wide access to hardware parts. For example, controlling the camera lens manually with a slider, the same applies for the flash intensity and capturing frame rate.

As far as I know, all the device functionality should be made available and documented by the device driver before working on the API. Unfortunately, I've been asked (as a C/C++ developer) to start designing the API as a method to guide the production process by its final deliverable functionality.

So is there any work for a developer to do before having the device driver?

Also, could you please provide me a sample code (pseudo code) of how an API makes use of device driver to perform some functionality?


Solution

  • Designing an API usually just means writing a C-language header file with the names of the methods your library provides, along with their arguments, return types, and any necessary documentation. So, yes, you can certainly start writing that file before you have a device driver.

    Since you have two separate questions, I think you should have posted them separately on this site. But anyway, the answer to your second question depends heavily on what operating system you are using. In Windows, you would probably use DeviceIoControl and in Linux you would probably use ioctl (or just read and write).