{"id":22562435,"url":"https://github.com/alc6/ads-stm32","last_synced_at":"2025-03-28T12:43:07.204Z","repository":{"id":210400355,"uuid":"237306280","full_name":"alc6/ads-stm32","owner":"alc6","description":"Bend Labs Angular Displacement Sensor STM32  ST HAL/CubeMX Library ","archived":false,"fork":false,"pushed_at":"2020-01-30T21:46:26.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T13:16:57.860Z","etag":null,"topics":["ads","bend","cubemx","labs","stm32"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alc6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-01-30T21:09:34.000Z","updated_at":"2020-01-30T21:46:28.000Z","dependencies_parsed_at":"2023-12-02T14:49:24.518Z","dependency_job_id":null,"html_url":"https://github.com/alc6/ads-stm32","commit_stats":null,"previous_names":["alc6/ads-stm32"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alc6%2Fads-stm32","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alc6%2Fads-stm32/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alc6%2Fads-stm32/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alc6%2Fads-stm32/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alc6","download_url":"https://codeload.github.com/alc6/ads-stm32/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246034275,"owners_count":20712851,"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":["ads","bend","cubemx","labs","stm32"],"created_at":"2024-12-07T22:13:31.931Z","updated_at":"2025-03-28T12:43:07.181Z","avatar_url":"https://github.com/alc6.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bend labs ADS Sensor STM32 ST HAL/Cube MX Library\n\n\n\n## Features\n* Polling mode \n* Ready for multi-devices use\n\n\n## Features to be implemented in future\n* Address management\n* Interrupt mode\n* Provide an example application with Nucleo F401\n* Provide easier FreeRTOS compatibility\n\n\n\n\n\n## Example\n\n### With the CubeMX project (.ioc file) provided generating the code\n\nA Nucleo F401RE is required. \n\nThe example shows the concurrent use of 3 devices and have been tested with one and two axis devices. \n\nWe assume that you:\n* You redirected the printf function to write on an known output (USART1 for this kind of Nucleo)\n* You enabled \n\n1. Generate the CubeMX project\n2. Redirect the printf function to write on the output you want (ITM, or UART)\n3. Enable float printf by adding \"-u _printf_float\" in the Linker flags\n4. Add the following code section in Src/freertos.c : \n\n``` c\n#include \"i2c.h\"\n#include \"ads_hal.h\"\n#include \"ads.h\"\n```\n``` c\n#define USING_ONE_AXIS_SENSORS 1\n#define USING_TWO_AXIS_SENSORS 0\n\n#if USING_ONE_AXIS_SENSORS\n    #define SENSOR_1_ADDRESS 0x08\n#elif USING_TWO_AXIS_SENSORS\n    #define SENSOR_1_ADDRESS 0x10\n#endif\n\n#if USING_ONE_AXIS_SENSORS\n    #define SENSOR_2_ADDRESS 0x09\n#elif USING_TWO_AXIS_SENSORS\n    #define SENSOR_2_ADDRESS 0x11\n#endif\n\n#if USING_ONE_AXIS_SENSORS\n    #define SENSOR_3_ADDRESS 0x0A\n#elif USING_TWO_AXIS_SENSORS\n    #define SENSOR_3_ADDRESS 0x12\n#endif\n```\n``` c\nchar getChar();\nvoid calibrate(ads_handler_t * h)\n{\n\tchar c;\n\tc = getChar();\n\n\tads_calibrate(h, 0, 0);\n  if (h-\u003etype == ADS_TWO_AXIS)\n  {\n    printf(\"Good. Now press a key when the sensor is straight from base but 90 degrees up from table (along Y axis)\\n\");\n\n    c = getChar();\n\n    ads_calibrate(h, ADS_CALIBRATE_PERP, 90);\n  }\n  printf(\"Good. Now press a key when the sensor is flat on table but bent at 90 degrees (along X axis)\\n\");\n  c = getChar();\n\n  ads_calibrate(h, 1, 90);\n\n  printf(\"Calibration complete.\\n\");\n}\nchar getChar()\n{\n\tuint8_t buf[0];\n    HAL_StatusTypeDef res1;\n\n    do {\n    \tres1 = HAL_UART_Receive(\u0026huart2, buf, 1, 0x0A);\n\t\t  if (ads_poll_data(\u0026ads1))\n\t\t  {\n\t\t\t  printf(\"%.1f\\n\", ads1.data[0]);\n\t\t  }\n    } while (res1 != HAL_OK);\n    return buf[0];\n}\n```\n5. Place the following code section in the StartDefaultTask generated by CubeMX:\n``` c\n\n\tads_handler_t ads1;\n\tads_handler_t ads2;\n\tads_handler_t ads3;\n\n\tbool getDataFlag = true;\n\n\t/* Let the HAL know which i2c handler is being used */\n\tads_hal_set_i2c_handler(\u0026hi2c1);\n\n\t/* Set parameters */\n\tmemset(\u0026ads1, 0, sizeof(ads_handler_t));\n\tads1.comSize = ADS_TRANSFER_SIZE_ONE_AXIS;\n\tads1.sps = ADS_100_HZ;\n\tads1.i2c_address = SENSOR_1_ADDRESS;\n\tads1.reset_pin = GPIO_PIN_0;\n\tads1.reset_port = (void*) GPIOC;\n\tads1.interrupt_mode = 0; //disable the interrupt mode\n\n\tmemset(\u0026ads2, 0, sizeof(ads_handler_t));\n\tads2.comSize = ADS_TRANSFER_SIZE_ONE_AXIS;\n\tads2.sps = ADS_100_HZ;\n\tads2.i2c_address = SENSOR_2_ADDRESS;\n\tads2.reset_pin = GPIO_PIN_1;\n\tads2.reset_port = (void*) GPIOC;\n\tads2.interrupt_mode = 0; //disable the interrupt mode\n\n\tmemset(\u0026ads3, 0, sizeof(ads_handler_t));\n\tads3.comSize = ADS_TRANSFER_SIZE_ONE_AXIS;\n\tads3.sps = ADS_100_HZ;\n\tads3.i2c_address = SENSOR_3_ADDRESS;\n\tads3.reset_pin = GPIO_PIN_2;\n\tads3.reset_port = (void*) GPIOC;\n\tads3.interrupt_mode = 0; //disable the interrupt mode\n\n\tads_init(\u0026ads1); /* Init */\n\tads_init(\u0026ads2); /* Init */\n\tads_init(\u0026ads3); /* Init */\n\tosDelay(150);\n\n  /* Infinite loop */\n  for(;;)\n  {\n\t  if (getDataFlag)\n\t  {\n\t\t  if (ads_poll_data(\u0026ads1))\n\t\t  {\n\t\t\t  printf(\"%.1f\\n\", ads1.data[0]);\n\t\t  }\n\t\t  if (ads_poll_data(\u0026ads2))\n\t\t  {\n\t\t\t  printf(\"%.1f\\n\", ads2.data[0]);\n\t\t  }\n\t\t  if (ads_poll_data(\u0026ads3))\n\t\t  {\n\t\t\t  printf(\"%.1f\\n\", ads3.data[0]);\n\t\t  }\n\t  }\n    osDelay(100);\n\n    // Quick way to get an input from the user to see if we need to calibrate or enable/disable the stream\n    memset(tbuf, 0, 16);\n    HAL_StatusTypeDef res1;\n    res1 = HAL_UART_Receive(\u0026huart2, tbuf, 1, 0x0A);\n    if (res1 == HAL_OK)\n    {\n    \tprintf(\"Input: %c\\n\", tbuf[0]);\n    \tif (tbuf[0] == 'a')\n    \t{\n    \t\tads_calibrate(\u0026ads1, ADS_CALIBRATE_FIRST, 0);\n    \t\tads_calibrate(\u0026ads2, ADS_CALIBRATE_FIRST, 0);\n    \t}\n    \telse if (tbuf[0] == 'b')\n    \t{\n    \t\tads_calibrate(\u0026ads1, ADS_CALIBRATE_FLAT, 90);\n    \t\tads_calibrate(\u0026ads2, ADS_CALIBRATE_FLAT, 90);\n    \t}\n    \telse if (tbuf[0] == 'c')\n    \t{\n    \t\tcalibrate(\u0026ads1);\n    \t}\n    \telse if (tbuf[0] == 'd')\n    \t{\n    \t\tgetDataFlag = 1;\n    \t}\n    \telse if (tbuf[0] == 'e')\n    \t{\n    \t\tgetDataFlag = 0;\n    \t}\n    }\n  }\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falc6%2Fads-stm32","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falc6%2Fads-stm32","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falc6%2Fads-stm32/lists"}