Skip to main content

small utility to generate Pos and Msk definitions for registers, particularly for CMSIS projects

Project description

Overview

cmsis_posmsk_codegen is a small utility to generate Pos and Msk definitions for registers, particularly for CMSIS projects. It can be used for any project but the Pos and Msk definitions are compatible with other definitions in CMSIS v5.

Installation

$ pip install cmsis_posmsk_codegen

then use:

$ cmsis_posmsk_codegen reg.yaml

Register Definition (yaml)

One or more registers are defined in a yaml file like this:

REG_1:
  - FIELD_1: 2
  - FIELD_2: 3
  - RESERVED: 27
REG_2
  - RESERVED: 3
  - RESERVED: 5
  - FIELD_1: 24

The field names are taken as it is for code generation. Since the generated code is C definitions, you probably want to write both register and field names in upper case.

The number next to field name after colon is the number of bits of this field. It is assumed registers are 32-bit, so the total of bits of all fields in a register definiiton has to be 32-bit. If it is not, an error is generated and no output is given.

If a field name is called RESERVED, no definition is generated, and its bits are skipped. Since this field is not generated, there can be more than one field named RESERVED. However, any other name (both registers and fields) has to be unique. If you want to keep a reserved field, name it with a number like RESERVED0.

A yaml file like above generates a Pos and Msk definition pair like this one for each field (so in total 3 pairs for example above, omitting the ones called RESERVED):

#define ETM_REG_1_FIELD_1_Pos   2U
#define ETM_REG_1_FIELD_1_Msk   (3UL << ETM_REG_1_FIELD_1_Pos)

An example yaml, etm.yaml, is given in github repo (but not in PyPI package). It describes ARM ETM registers.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmsis_posmsk_codegen-1.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file cmsis_posmsk_codegen-1.tar.gz.

File metadata

  • Download URL: cmsis_posmsk_codegen-1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.9

File hashes

Hashes for cmsis_posmsk_codegen-1.tar.gz
Algorithm Hash digest
SHA256 571ffe954f25778f6e9d52dc3ee0090136d0389a9ca595ad92d053c1e5a5efd2
MD5 efc39dfff03c5d05af8536b1d9ad40d0
BLAKE2b-256 b14d40adfccb43490a444ae435ebecd8c12c18742be972f91b2affd4d1fa3ace

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page