{"id":13780900,"url":"https://github.com/chrismoos/avr-os","last_synced_at":"2025-05-11T14:34:18.190Z","repository":{"id":5812249,"uuid":"7027223","full_name":"chrismoos/avr-os","owner":"chrismoos","description":"Multitasking OS for Arduino and AVR platforms","archived":false,"fork":false,"pushed_at":"2017-02-01T06:23:31.000Z","size":1259,"stargazers_count":129,"open_issues_count":5,"forks_count":26,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-17T16:41:52.257Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrismoos.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}},"created_at":"2012-12-06T00:33:34.000Z","updated_at":"2024-02-11T16:33:57.000Z","dependencies_parsed_at":"2022-07-16T19:00:39.090Z","dependency_job_id":null,"html_url":"https://github.com/chrismoos/avr-os","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismoos%2Favr-os","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismoos%2Favr-os/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismoos%2Favr-os/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismoos%2Favr-os/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrismoos","download_url":"https://codeload.github.com/chrismoos/avr-os/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253580223,"owners_count":21930905,"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":[],"created_at":"2024-08-03T18:01:20.936Z","updated_at":"2025-05-11T14:34:17.845Z","avatar_url":"https://github.com/chrismoos.png","language":"C","funding_links":[],"categories":["Miscellaneous"],"sub_categories":[],"readme":"# avr-os\n\n[![Build Status](https://travis-ci.org/chrismoos/avr-os.png?branch=master)](https://travis-ci.org/chrismoos/avr-os)\n\navr-os is a library that provides a very basic rutime that enables your program to multitask.\n\nThe library uses pre-emptive multitasking to switch tasks and each task has its own stack that is restored when a task is resumed. An AVR timer is used to provide ticks and this interrupt is used to switch tasks.\n\n## Adding library to Arduino\n\n    git clone git://github.com/chrismoos/avr-os.git ~/Documents/Arduino/libraries/avros\n\n## Building\n\nYou can create a static library for avr-os by issuing the following command:\n\n    make DEVICE=arduino_uno\n\n## Supported devices\n\n* arduino_uno\n* arduino_mega\n* arduino_mega2560\n\n## Arduino/AVR specific\n\n### Choosing a timer\n\nThe following timers are supported by *avr-os* to use for multitasking:\n\n* TIMER0 (8-bit)\n* TIMER1 (16-bit)\n* TIMER2 (8-bit)\n\nWhen building use the **CONFIG_AVR_TIMER** flag. For example, to specify TIMER2 to be used:\n\n    make CONFIG_AVR_TIMER=2 DEVICE=arduino_uno\n\n*Note*: TIMER1 is the default timer if not specified.\n\n## License\n\nCopyright 2012 Chris Moos\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n## Sample sketch\n\nThis sketch has two tasks that update the LCD.\n\n![example](https://raw.github.com/chrismoos/avr-os/master/example.png)\n\n```cpp\n#include \u003cArduino.h\u003e\n#include \u003cLiquidCrystal.h\u003e\n\n#include \u003cutil/delay.h\u003e\n\nextern \"C\" {\n    #include \u003cos.h\u003e\n}\n\nLiquidCrystal lcd(12, 11, 5, 4, 3, 2);\n\nspinlock_t testLock;\n\nvoid kernel_task(void *arg) {\n    while(1) {\n        spinlock_acquire(\u0026testLock);\n        lcd.setCursor(0, 0);\n        lcd.print(\"kernel: \" + String((long)os_get_uptime()));\n        spinlock_release(\u0026testLock);\n        os_sleep(1000);\n    }\n}\n\nvoid user_task(void *arg) {\n    int x = 0;\n    while(1) {\n        spinlock_acquire(\u0026testLock);\n        lcd.setCursor(0, 1);\n        lcd.print(\"user_task: \" + String(x++));\n        spinlock_release(\u0026testLock);\n        os_sleep(5000);\n    }\n}\n\nvoid setup() {\n    os_init();\n    lcd.begin(16, 2);\n    lcd.print(\"Starting up...\");\n}\n\nvoid loop() {\n    spinlock_init(\u0026testLock);\n\n    os_schedule_task(kernel_task, NULL, 0);\n    os_schedule_task(user_task, NULL, 0);\n    lcd.clear();\n    os_loop(); \n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismoos%2Favr-os","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrismoos%2Favr-os","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismoos%2Favr-os/lists"}