{"id":19091232,"url":"https://github.com/chmorgan/go-pwm-example","last_synced_at":"2025-07-14T16:05:11.641Z","repository":{"id":57531779,"uuid":"172340735","full_name":"chmorgan/go-pwm-example","owner":"chmorgan","description":"golang example of pwm interaction using sysfs","archived":false,"fork":false,"pushed_at":"2019-03-17T01:27:14.000Z","size":8,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T11:03:17.953Z","etag":null,"topics":["golang","linux","onion-omega2","pwm","sysfs"],"latest_commit_sha":null,"homepage":"","language":"Go","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/chmorgan.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":"2019-02-24T13:27:05.000Z","updated_at":"2023-03-15T23:24:18.000Z","dependencies_parsed_at":"2022-09-06T16:30:50.376Z","dependency_job_id":null,"html_url":"https://github.com/chmorgan/go-pwm-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chmorgan/go-pwm-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmorgan%2Fgo-pwm-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmorgan%2Fgo-pwm-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmorgan%2Fgo-pwm-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmorgan%2Fgo-pwm-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chmorgan","download_url":"https://codeload.github.com/chmorgan/go-pwm-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmorgan%2Fgo-pwm-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265314164,"owners_count":23745208,"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":["golang","linux","onion-omega2","pwm","sysfs"],"created_at":"2024-11-09T03:12:50.560Z","updated_at":"2025-07-14T16:05:11.581Z","avatar_url":"https://github.com/chmorgan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\nExample golang application that makes use of the hardware PWM channels.\n\nWritten as an example for the Onion Omega2 but this would serve as a good example for a number of\ncompute modules that have PWM hardware exposed to Linux.\n\n# Dependencies\n\ngobot.io's sysfs module is used to provide access to the pwm hardware\n\n# How to build\n\nThe project has been updated to take advantage of go's new module support. This makes it\neasy to build.\n\n```\n\u003cgo to where you'd like to place the 'go-pwm-example' directory\u003e\ngit clone https://github.com/chmorgan/go-pwm-example.git\ncd go-pwm-example\ngo build\n```\n\n## Build for the Omega2\n\ngolang has support for a number of architectures built in, this makes it well suited for cross platform\ndevelopment.\n\nThe Omega2 uses a MediaTek MT7688 SoC. This processor is a mips architecture and little endian is being used.\nTherefore the architecture is 'mips' + 'le', or 'mipsle'.\n\n```\nGOOS=linux GOARCH=mipsle go build\n```\n\nYou should now have a 'go-pwm-example' application in the current directory.\n\n## Copy to your Omega2\n\nReplace 'xxxx' with the address of your Omega.\n\n```\nscp go-pwm-example root@omega-xxxx.local:/root/\n```\n\n# How to run\n\n## Pin mux configuration\nNote: Pin muxing must be set appropriately for the pwm channel being used.\n\nFor example:\n```\n# omega2-ctrl gpiomux get\nGroup i2c - [i2c] gpio\nGroup uart0 - [uart] gpio\nGroup uart1 - [uart] gpio pwm01\nGroup uart2 - [uart] gpio pwm23\nGroup pwm0 - pwm [gpio]\nGroup pwm1 - pwm [gpio]\nGroup refclk - refclk [gpio]\nGroup spi_s - spi_s [gpio] pwm01_uart2\nGroup spi_cs1 - [spi_cs1] gpio refclk\nGroup i2s - i2s [gpio] pcm\nGroup ephy - [ephy] gpio\nGroup wled - wled [gpio]\n```\n\nAssuming we are using pwm channel 0 (GPIO18) you'll reconfigure this pin for pwm mode via:\n```\n# omega2-ctrl gpiomux set pwm0 pwm\nset gpiomux pwm0 -\u003e pwm\n```\n\n## Running\n```\n./go-pwm-example\n```\n\nAnd to get command line help you can pass the '-help' option:\n\n```\n# ./go-pwm-example -help\nUsage of ./go-pwm-example:\n  -channel int\n    \tPWM channel (0, 1, 2, or 3)\n  -frequency float\n    \tFrequency in Hz (default 100)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchmorgan%2Fgo-pwm-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchmorgan%2Fgo-pwm-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchmorgan%2Fgo-pwm-example/lists"}