Does anybody know if there is example code to USB on a AVR with freepascal example code? Including freepascal example code for the WIN32 driver ?
You have to be more specific, since this contradicts to your drawing where you use 328P AVRs which do not have USB hardware on them and direct USB connection to Pi or pc. If they do not talk USB, why you need AVR freepascal code on AVR?
In general, there are many ways to skin a cat. Some are easy, some are complex, and some might not be available for your favorite hardware or language. We might be talking about USB capable MCU which we might access via USB CDC as a virtual serial port without need for a custom driver, or access directly via libusb and some custom code. Or we might be talking about USB uncapable MCU which we might access using some USB<>TTL bridge chip like CH340 or FT232R and use manufacturer USB driver to use it as a virtual serial port or bitbang GPIO. It is not 100% clear what are you trying to achieve. We might even be talking about AVRs where we would like to emulate USB CDC or USB HID in software and use them as if they are real USB devices. See how much possibilities are there?
The idea is to build a new enclosure with 6 UARTs on it to connect to your WIN32 machine without using a old UART serial port.
If I understood well, the idea would be to have 6 bidirectional UARTS connected to Windows pc without using classic RS232 DB9 ports, and implementation details would be to have Raspberry Pi Zero connected via i2c to 6 AVRs and read/write their UART streams, and having Pi deliver all that data to Windows pc over USB, and having a way to physically switch on/off each channel and display it's status over leds and display? Is that right?
If I had to do it, I would make it with a much lower complexity, by simply using out of the shelf components like CH348 which supports up to 8 ports and even has enough GPIO to control leds, switches, and even a display, using provided virtual serial port for communication and DLL for GPIO. You can test it for cheap (
https://www.aliexpress.com/item/1005005677493754.html), find more info (
https://www.cnx-software.com/2022/03/04/wch-ch348-8-port-usb-to-serial-chip-with-up-to-48-gpios/), or read datasheet directly. Going more closer to your route, I would choose AVR with many UARTS (ATxmega128A1U has 8 UARTS and no USB HW, ATxmega32A4U has only 5 UARTS but has USB HW) and avoid using Pi at all. You could also use some USB FTDI chip to access your 6 AVRs over I2C, but without simple virtual serial port access you would have to deal your self with quite a lot manually.