{"id":25765349,"url":"https://github.com/zenitheesc/platform-lib","last_synced_at":"2025-11-22T07:02:30.041Z","repository":{"id":276857120,"uuid":"930516392","full_name":"zenitheesc/Platform-Lib","owner":"zenitheesc","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-25T23:57:07.000Z","size":65,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-26T00:27:08.787Z","etag":null,"topics":["arduino","arduino-ide","c","cplusplus","cube-ide","embedded-systems","esp32","platformio","stm32"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zenitheesc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-10T18:58:47.000Z","updated_at":"2025-02-25T23:57:10.000Z","dependencies_parsed_at":"2025-02-26T00:24:02.694Z","dependency_job_id":"fded7420-8b66-4ef8-86e7-9674c4657c4f","html_url":"https://github.com/zenitheesc/Platform-Lib","commit_stats":null,"previous_names":["zenitheesc/platform-lib"],"tags_count":0,"template":false,"template_full_name":"zenitheesc/new-zenith-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenitheesc%2FPlatform-Lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenitheesc%2FPlatform-Lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenitheesc%2FPlatform-Lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenitheesc%2FPlatform-Lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenitheesc","download_url":"https://codeload.github.com/zenitheesc/Platform-Lib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240941514,"owners_count":19882063,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","arduino-ide","c","cplusplus","cube-ide","embedded-systems","esp32","platformio","stm32"],"created_at":"2025-02-26T22:18:12.247Z","updated_at":"2025-11-22T07:02:30.035Z","avatar_url":"https://github.com/zenitheesc.png","language":"C","readme":"\u003ch1 align=\"center\" style=\"color:white; background-color:black\"\u003ePlatform Lib\u003c/h1\u003e\n\u003ch4 align=\"center\"\u003eThe project was created to refactor and finish the lib platform, which was begun for the old members of Zenith to enable some drivers (utilizing the lib) for embedded systems with different microcontrollers.\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"http://zenith.eesc.usp.br/\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Zenith-Embarcados-black?style=for-the-badge\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://eesc.usp.br/\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Linked%20to-EESC--USP-black?style=for-the-badge\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/zenitheesc/Platform-Lib/blob/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/zenitheesc/Platform-Lib?style=for-the-badge\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/zenitheesc/Platform-Lib/issues\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues/zenitheesc/Platform-Lib?style=for-the-badge\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/zenitheesc/Platform-Lib/commits/main\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/commit-activity/m/zenitheesc/Platform-Lib?style=for-the-badge\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/zenitheesc/Platform-Lib/graphs/contributors\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/contributors/zenitheesc/Platform-Lib?style=for-the-badge\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/zenitheesc/Platform-Lib/commits/main\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/last-commit/zenitheesc/Platform-Lib?style=for-the-badge\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/zenitheesc/Platform-Lib/issues\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/issues-raw/zenitheesc/Platform-Lib?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/zenitheesc/Platform-Lib/pulls\"\u003e\n    \u003cimg src = \"https://img.shields.io/github/issues-pr-raw/zenitheesc/Platform-Lib?style=for-the-badge\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n#  Platform.h\n## Objective\n\nPlatform headers is an abstraction layer to help application drivers to be\nplatform agnostic. That means that including the header will provide a\ncommon interface between our embedded platforms such as STM32 (HAL) or \nArduino. \n\n## Scope\n\nEach platform implementation provides access to common (internal) peripherals,\nsuch as I2C, SPI, UART and ADCs. As it's expected to be implemented in various \ncircumstances, the scope is limited to transmitting and receiving raw bytes.\n\n## Usage\nE\nJust add the `platform/` folder to the project, then\n `#include \"platform.h\"` in the driver. It then checks for \npreprocessor macros to detect which platform is being compiled.\nFor STM32, it will also attempt to find the proper chip family HAL. \nIf a platform is not found it is assumed to be running on a PC.\nThis means calls will be logged to `stdout` with no side-effects.\n\n## Notes\nIf you're using an arduino (or esp-idf) implementation, put the `#include \"platform/platform.h\" after\nincludes to other arduino (or esp-idf) libraries.\n\n## To do\nFinish that tasks later\n\n* CAN protocol functions in Platform:\n- [ ] arduinoIDE\n- [ ] STM32 (cubeIDE)\n\n* Interrupts use functions:\n- [ ] arduinoIDE\n- [ ] STM32 (cubeIDE)\n\n* DMA use functions:\n- [ ] arduinoIDE\n- [ ] STM32 (cubeIDE)\n\n* Implementation of Platform-Lib for ESP32 using expressifeIDE\n\n## Specification\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"#common\"\u003eCommon\u003c/a\u003e •\n    \u003ca href=\"#gpio\"\u003eGPIO\u003c/a\u003e •\n    \u003ca href=\"#i2c\"\u003eI2C\u003c/a\u003e •\n    \u003ca href=\"#spi\"\u003eSPI\u003c/a\u003e •\n    \u003ca href=\"#uart\"\u003eUART\u003c/a\u003e •\n    \u003ca href=\"#adc\"\u003eADC\u003c/a\u003e •\n    \u003ca href=\"#pwm\"\u003ePWM\u003c/a\u003e \n\u003c/p\u003e\n\n### Common\n\n#### Types\n - `error_t`\n ```c\n  typedef int error_t;\n ```\n This is a common error code type, it is recommended to be an underlying `int` but can also be a platform specific. The requirement is that \n evaluation of no error is false. So essentially, that the following pattern\n still applies:\n ```c\n  if(error){\n    // error handling...\n  }\n  // ... code assuming no errors\n ``` \nThis pattern was chosen to prevent [Indent Hadouken](https://i.pinimg.com/originals/98/bd/38/98bd38321fad0e8b14ebf3a5a9ec70c9.jpg)\n \n - `buffer_view_t`\n```c\ntypedef struct {\n  uint8_t *data;\n  int size;\n} buffer_view_t;\n```\n\nIt's used to pass pointers to `data` buffers of `size`. It is used throughout \nthis header to pass a bunch of bytes. This was chosen to keep things simple \nand prevent mixing up sizes and arrays.\n \n - `result{8,16,float}_t`\n```c\ntypedef struct {\n  error_t hasError;\n  uint8_t value;\n} result8_t;\n\n```\n\nThe `results` are a complement to the error handling strategy. Because \nthere are no parameters in C, the platform header only creates result types\nfor common types: `uint8_t`, `uint16_t` and `float`. Other result types\nshould be declared on a driver-by-driver basis.\n\n\n#### Functions\n - `delay_ms`\n ```c\n  void delay_ms(uint32_t time);\n ```\n A blocking millisecond delay. It is recommended that RTOS use be \n detected via preprocessor macros, so that drivers can take advantage.\n\n### GPIO\n\n#### Types\n\n- `gpio_pin_t`\n ```c\ntypedef struct {\n  \u003cPORT\u003e *port;\n  uint16_t pin;\n} gpio_pin_t;\n ```\n GPIO Pin Type\n\n- `gpio_state_t`\n ```C\ntypedef enum{\n  gpio_low_level = 0U,\n  gpio_high_level\n} gpio_state_t\n ```\n GPIO state type\n\n #### Functions\n - `gpio_read`\n ```c\n gpio_state_t gpio_read(gpio_pin_t pin);\n ```\n\n - `gpio_low` \n \n ```c\n void gpio_low(gpio_pin_t pin);\n ```\n Reset GPIO\n\n - `gpio_high` \n \n ```c\n void gpio_high(gpio_pin_t pin);\n ```\n Set GPIO\n\n - `gpio_toggle` \n \n ```c\n void gpio_toggle(gpio_pin_t pin);\n ```\n Toggle GPIO\n\n### I2C\n\n#### Types\n\n- `i2c_t`\n ```c\n  typedef \u003cI2C_Type\u003e i2c_dev_t;\n ```\n\n I2C Interface Type\n\n- `i2c_dev_t`\n```c\ntypedef struct {\n  i2c_t *i2c;\n  uint8_t address;\n} i2c_device_t;\n```\n\n I2C Device Type\n \n #### Functions\n\n - `i2c_transmit` \n \n ```c\n error_t i2c_transmit(i2c_device_t device, buffer_view_t buffer);\n ```\n Transmit bytes via I2C\n\n\n - `i2c_receive` \n \n ```c\n error_t i2c_receive(i2c_device_t device, buffer_view_t buffer);\n ```\n Receive bytes via I2C\n### SPI\n\n#### Types\n- `spi_t`\n```c\n  typedef \u003cSPI_Type\u003e spi_t;\n```\n SPI Interface Type\n\n- `spi_dev_t`\n```c\ntypedef struct {\n  spi_t *spi;\n  gpio_pin_t pin;\n} spi_device_t;\n```\n SPI Device Type\n \n#### Functions\n\n - `spi_transceive`\n```c\nerror_t spi_transceive(spi_device_t device, buffer_view_t rx_buffer, \n  buffer_view_t tx_buffer);\n```\n\nTransceive (Transmit and Receive) via SPI\n\n - `spi_transmit`\n```c\nerror_t spi_transmit(spi_device_t device, buffer_view_t tx_buffer);\n```\n\nTransmit via SPI\n\n - `spi_transceive`\n```c\nerror_t spi_receive(spi_device_t device, buffer_view_t rx_buffer);\n```\n\nReceive via SPI\n### UART\n\n#### Types\n\n - `uart_t`\n ```c\n  typedef \u003cUART_Type\u003e uart_t;\n ```\n UART Interface Type\n\n- `uart_connection_t`\n```c\ntypedef struct {\n  uart_t *uart;\n} uart_connection_t;\n```\nUART Connection Type\n #### Functions\n - `uart_init`\n```c\nvoid uart_init(uart_connection_t conn, uint32_t baudRate, uint32_t timeOut);\n```\n\n - `uart_transmit`\n```c\nerror_t uart_transmit(uart_connection_t conn, buffer_view_t buffer);\n```\nTransmit bytes via UART\n\n - `uart_receive`\n```c\nerror_t uart_receive(uart_connection_t conn, buffer_view_t buffer);\n```\nReceive bytes via UART\n\n### ADC\n\n#### Types\n - `adc_handle_t`\n```c\ntypedef \u003cADC_Type\u003e adc_handle_t;\n```\nADC Channel Type\n- `adc_t`\n```c\ntypedef struct {\n  adc_handle_t handle;\n  uint8_t bits;\n  float voltage_reference;\n} adc_t;\n```\nADC Type\n\n#### Functions\n\n - `adc_init`\n```c\nerror_t adc_init(adc_t *adc);\n```\nADC initialization \n\n - `adc_read`\n```c\nresult_uint16_t adc_read(adc_t *adc);\n```\nADC Read raw value\n\n - `adc_raw_to_voltage`\n```c\nfloat adc_raw_to_voltage(const adc_t *adc, const uint16_t value);\n```\n\nADC conversion to volts.\n\n### PWM\n\n#### Types\n\n - `pwm_handle_t`\n```c\ntypedef \u003cPWM_Handle_Type\u003e pwm_handle_t;\n```\nPWM Handle Type\n\n\n - `pwm_channel_t`\n```c\ntypedef \u003cPWM_Channel_Type_\u003e pwm_channel_t;\n```\nPWM Channel Type\n\n - `pwm_t`\n```c\ntypedef struct {\n  pwm_handle_t handle;\n  pwm_channel_t channel;\n  uint8_t bits;\n} pwm_t;\n```\nPWM Type\n\n#### Functions\n\n - `pwm_start`\n```C\nerror_t pwm_start(pwm_t pwm)\n```\nPWM start conection\n\n - `pwm_write`\n```c\nerror_t pwm_write(pwm_t pwm)\n```\nPWM module signal\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"http://zenith.eesc.usp.br\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Check%20out-Zenith's Oficial Website-black?style=for-the-badge\" /\u003e\n    \u003c/a\u003e \n    \u003ca href=\"https://www.facebook.com/zenitheesc\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Like%20us%20on-facebook-blue?style=for-the-badge\"/\u003e\n    \u003c/a\u003e \n    \u003ca href=\"https://www.instagram.com/zenith_eesc/\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Follow%20us%20on-Instagram-red?style=for-the-badge\"/\u003e\n    \u003c/a\u003e\n\n\u003c/p\u003e\n\u003cp align = \"center\"\u003e\n\u003ca href=\"zenith.eesc@gmail.com\"\u003ezenith.eesc@gmail.com\u003c/a\u003e\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenitheesc%2Fplatform-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenitheesc%2Fplatform-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenitheesc%2Fplatform-lib/lists"}