Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Super /Mega Linter #1

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
8cfff98
Added Super Linter
ScottGibb Nov 20, 2024
182aa29
added Linting badge
ScottGibb Nov 20, 2024
59f25af
Added Markdownlint settings
ScottGibb Nov 20, 2024
e32a1b1
Turning on linters for all file types present in repo
ScottGibb Nov 20, 2024
02ca4ac
disabling on push trigger
ScottGibb Nov 20, 2024
8b80603
added Rust linting
ScottGibb Nov 20, 2024
97f0d3c
changed markdownlint from json to yaml
ScottGibb Nov 20, 2024
9e1acb2
Fixed Markdown linting issues
ScottGibb Nov 20, 2024
1a2f1b9
updated all ReadMe Violations
ScottGibb Nov 20, 2024
2b5a2aa
Adding lint fixing
ScottGibb Nov 20, 2024
f45055a
Added fmt stage
ScottGibb Nov 20, 2024
5740033
Added .gitignore
ScottGibb Nov 20, 2024
1c44ac3
Updated linting and formatting
ScottGibb Nov 20, 2024
e275a84
Added Checkout Code Stage
ScottGibb Nov 20, 2024
e405099
Added Clippy and fmt into workflow
ScottGibb Nov 20, 2024
502d2b9
Updating src fmt
ScottGibb Nov 20, 2024
a703659
Fixed clippy issue
ScottGibb Nov 22, 2024
7818031
Added comment about issue
ScottGibb Nov 22, 2024
e7bee80
Added linting rules
ScottGibb Nov 22, 2024
44e0667
Added todo
ScottGibb Nov 22, 2024
54c84f9
Fixed script formatting
ScottGibb Nov 22, 2024
593a20f
Fixed badge
ScottGibb Nov 22, 2024
4a2d876
Added some new linters
ScottGibb Nov 22, 2024
604f94f
using ` instead of ```
ScottGibb Nov 22, 2024
265842c
removed "such as baremetal"
ScottGibb Nov 22, 2024
1c5c78c
Adding markdown glob that should catch all files now
ScottGibb Nov 22, 2024
2b7061e
Fixed README docs
ScottGibb Nov 22, 2024
b534acf
Adding Lint Fixing Workflow
ScottGibb Nov 22, 2024
3239bbe
added Textlint rules
ScottGibb Nov 22, 2024
b66f400
removed extra spaces
ScottGibb Nov 22, 2024
cfce6f6
Updated README
ScottGibb Nov 22, 2024
96529fe
Attempting to fix linter fix stage
ScottGibb Nov 22, 2024
9a1d28e
Attempt at fixing linter
ScottGibb Nov 22, 2024
04b7d8d
test
ScottGibb Nov 22, 2024
eb57892
Added Fix Flow
ScottGibb Nov 22, 2024
2773558
Fixed util readme issues
ScottGibb Nov 22, 2024
a5989fe
Attempt at using megalinter
ScottGibb Nov 22, 2024
1fe2957
added permissions
ScottGibb Nov 22, 2024
9d873f5
restructuring permissions
ScottGibb Nov 22, 2024
d86dd57
mega linter settings
ScottGibb Nov 22, 2024
e6ae701
removed the 'the'
ScottGibb Nov 25, 2024
9183a4c
configured megalinter
ScottGibb Nov 25, 2024
570d002
created two markdown errors
ScottGibb Nov 25, 2024
9bd1558
Messing around with CI configuration
ScottGibb Nov 25, 2024
653ba86
testing
ScottGibb Nov 25, 2024
2f2ee60
added MegaLinter
ScottGibb Nov 25, 2024
45c7284
updated linter
ScottGibb Nov 25, 2024
aedae88
fixed env variable
ScottGibb Nov 25, 2024
d36dfdb
possivble syntax error
ScottGibb Nov 25, 2024
5033865
reformatting
ScottGibb Nov 25, 2024
1246eee
test
ScottGibb Nov 25, 2024
9b5f461
attempting to fix the aply fix stage
ScottGibb Nov 25, 2024
87fde33
further testing
ScottGibb Nov 25, 2024
836dafa
ovveride
ScottGibb Nov 25, 2024
e8abc7f
reset workflow
ScottGibb Nov 25, 2024
e3d8e0e
Added more markdown lints
ScottGibb Nov 25, 2024
259dad2
Updated Megalinter settings
ScottGibb Nov 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 175 additions & 0 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# MegaLinter GitHub Action configuration file
# More info at https://megalinter.io
---
name: MegaLinter

# Trigger mega-linter at every push. Action will also be visible from Pull
# Requests to main
on: # yamllint disable-line rule:truthy - false positive
# Comment this line to trigger action only on pull-requests
# (not recommended if you don't pay for GH Actions)
push:

pull_request:
branches:
- main
- master

# Comment env block if you do not want to apply fixes
env:
# Apply linter fixes configuration
#
# When active, APPLY_FIXES must also be defined as environment variable
# (in github/workflows/mega-linter.yml or other CI tool)
APPLY_FIXES: all

# Decide which event triggers application of fixes in a commit or a PR
# (pull_request, push, all)
APPLY_FIXES_EVENT: pull_request

# If APPLY_FIXES is used, defines if the fixes are directly committed (commit)
# or posted in a PR (pull_request)
APPLY_FIXES_MODE: commit

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

permissions: {}

jobs:
megalinter:
name: MegaLinter
runs-on: ubuntu-latest

# Give the default GITHUB_TOKEN write permission to commit and push, comment
# issues & post new PR; remove the ones you do not need
permissions:
contents: write
issues: write
pull-requests: write

steps:
# Git Checkout
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}

# If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to
# improve performance
fetch-depth: 0

# MegaLinter
- name: MegaLinter

# You can override MegaLinter flavor used to have faster performances
# More info at https://megalinter.io/latest/flavors/
uses: oxsecurity/megalinter@v8

id: ml

# All available variables are described in documentation
# https://megalinter.io/latest/configuration/
env:
# Validates all source when push on main, else just the git diff with
# main. Override with true if you always want to lint all sources
#
# To validate the entire codebase, set to:
# VALIDATE_ALL_CODEBASE: true
#
# To validate only diff with main, set to:
# VALIDATE_ALL_CODEBASE: >-
# ${{
# github.event_name == 'push' &&
# contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref)
# }}
VALIDATE_ALL_CODEBASE: >-
${{
github.event_name == 'push' &&
contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref)
}}

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE
# .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY

# Uncomment to disable copy-paste and spell checks
# DISABLE: COPYPASTE,SPELL

# Upload MegaLinter artifacts
- name: Archive production artifacts
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: MegaLinter reports
path: |
megalinter-reports
mega-linter.log

# Set APPLY_FIXES_IF var for use in future steps
- name: Set APPLY_FIXES_IF var
run: |
printf 'APPLY_FIXES_IF=%s\n' "${{
steps.ml.outputs.has_updated_sources == 1 &&
(
env.APPLY_FIXES_EVENT == 'all' ||
env.APPLY_FIXES_EVENT == github.event_name
) &&
(
github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name == github.repository
)
}}" >> "${GITHUB_ENV}"

# Set APPLY_FIXES_IF_* vars for use in future steps
- name: Set APPLY_FIXES_IF_* vars
run: |
printf 'APPLY_FIXES_IF_PR=%s\n' "${{
env.APPLY_FIXES_IF == 'true' &&
env.APPLY_FIXES_MODE == 'pull_request'
}}" >> "${GITHUB_ENV}"
printf 'APPLY_FIXES_IF_COMMIT=%s\n' "${{
env.APPLY_FIXES_IF == 'true' &&
env.APPLY_FIXES_MODE == 'commit' &&
(!contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref))
}}" >> "${GITHUB_ENV}"

# Create pull request if applicable
# (for now works only on PR from same repository, not from forks)
- name: Create Pull Request with applied fixes
uses: peter-evans/create-pull-request@v6
id: cpr
if: env.APPLY_FIXES_IF_PR == 'true'
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
commit-message: "[MegaLinter] Apply linters automatic fixes"
title: "[MegaLinter] Apply linters automatic fixes"
labels: bot

- name: Create PR output
if: env.APPLY_FIXES_IF_PR == 'true'
run: |
echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}"

# Push new commit if applicable
# (for now works only on PR from same repository, not from forks)
- name: Prepare commit
if: env.APPLY_FIXES_IF_COMMIT == 'true'
run: sudo chown -Rc $UID .git/

- name: Commit and push applied linter fixes
uses: stefanzweifel/git-auto-commit-action@v4
if: env.APPLY_FIXES_IF_COMMIT == 'true'
with:
branch: >-
${{
github.event.pull_request.head.ref ||
github.head_ref ||
github.ref
}}
commit_message: "[MegaLinter] Apply linters fixes"
commit_user_name: megalinter-bot
commit_user_email: nicolas.vuillamy@ox.security
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Compiled files
/target/
utils/target/

# Dependency directories
Cargo.lock
Expand All @@ -13,4 +14,5 @@ Cargo.toml.bkp
*.rs.bk

# Editor-specific files
.idea/
.idea/
megalinter-reports/
7 changes: 0 additions & 7 deletions .markdownlint.json

This file was deleted.

34 changes: 34 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Configuration file for MegaLinter
#
# See all available variables at https://megalinter.io/latest/config-file/ and in
# linters documentation

# all, none, or list of linter keys
APPLY_FIXES: all

# If you use ENABLE variable, all other languages/formats/tooling-formats will
# be disabled by default
# ENABLE:

# If you use ENABLE_LINTERS variable, all other linters will be disabled by
# default
ENABLE_LINTERS:
- ACTION_ACTIONLINT
- RUST_CLIPPY
- MARKDOWN_MARKDOWNLINT
- MARKDOWN_MARKDOWN_LINK_CHECK
- MARKDOWN_MARKDOWN_TABLE_FORMATTER
- YAML_YAMLLINT
- COPYPASTE_JSCPD
# DISABLE:
# - COPYPASTE # Uncomment to disable checks of excessive copy-pastes
# - SPELL # Uncomment to disable checks of spelling mistakes

SHOW_ELAPSED_TIME: true

FILEIO_REPORTER: false

# Uncomment if you want MegaLinter to detect errors but not block CI to pass
DISABLE_ERRORS: false
GITHUB_COMMENT_REPORTER: true
GITHUB_STATUS_REPORTER: true
81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# TMAG5273 Rust Driver

[![Linting](https://github.com/dysonltd/tmag5273/actions/workflows/Linting.yaml/badge.svg)](https://github.com/dysonltd/tmag5273/actions/workflows/Linting.yaml)

## Summary
This is a platform agnostic Rust Driver for the TMAG52732 3 Axis I2C
Hall effect Sensor by Texas Instruments. The driver is based on the
[embedded-hal](https://github.com/rust-embedded/embedded-hal) traits.
For more information it is recommended to look at the docs using `cargo doc`
## The Device

An extract taken from the [Texas Instruments Datasheet](./docs/tmag5273.pdf):

>The TMAG5273 is a low-power linear 3D Hall-effect
sensor designed for a wide range of industrial
and personal electronics applications. This device
integrates three independent Hall-effect sensors in
the X, Y, and Z axes. A precision analog signal-chain
along with an integrated 12-bit ADC digitizes
the measured analog magnetic field values. The
I2C interface, while supporting multiple operating
VCC ranges, ensures seamless data communication
with low-voltage microcontrollers. The device has an
integrated temperature sensor available for multiple
system functions, such as thermal budget check or
temperature compensation calculation for a given
magnetic field.The TMAG5273 can be configured through the I2C
interface to enable any combination of magnetic
axes and temperature measurements. Additionally,
the device can be configured to various power
options (including wake-up and sleep mode) allowing
designers to optimize system power consumption
based on their system-level needs. Multiple sensor
conversion schemes and I2C read frames help
optimize throughput and accuracy. A dedicated
INT pin can act as a system interrupt during
low power wake-up and sleep mode, and can also be used by a
microcontroller to trigger a new sensor conversion.An integrated
angle calculation engine (CORDIC)
provides full 360° angular position information for both
on-axis and off-axis angle measurement topologies.
The angle calculation is performed using two
user-selected magnetic axes. The device features
magnetic gain and offset correction to mitigate the
impact of system mechanical error sources.The TMAG5273 is
offered in four different factory-programmed I2C addresses.
The device also supports additional I2C addresses through the modification
of a user-configurable I2C address register. Each
orderable part can be configured to select one of two
magnetic field ranges that suits the magnet strength
and component placement during system calibration.

## Examples

Examples on how to use the driver across multiple platforms can be found [here](./examples/README.md)

## Architecture Diagrams

The rough architecture of the files and directories of the project can be seen in
the following plantUML diagram.

![System Architecture](./docs/architecture.png)

As an application developer, you will spend most of your time working with the
TMAG5273 struct outlined in [lib.rs](./src/lib.rs). The device can initialised
by the `init_default` method and configuration can be done using the methods
outlined in [config.rs](./src/config.rs). However for fine grained control
of the device you can set and configure the raw registers outlined in the
folder [registers](./src/registers/). More information around the code can
be found using `cargo doc`.

## Helper Utilities

In this repository we also have an internal crate called [utils](./utils/) which contains some simple rust code for using the library on either Raspberry Pi or a Desktop Linux/Mac Machine.
For more information, please look at the following [README](./utils/README.md).

## Useful Links

- [Embedded Hal](https://docs.rs/embedded-hal/latest/embedded_hal/)
- [TMAG5273 Breakout Board](https://www.sparkfun.com/products/23880)
- [FT232H Breakout Board](https://www.adafruit.com/product/2264)
62 changes: 0 additions & 62 deletions ReadMe.md

This file was deleted.

Loading