:mod:`microcontroller` ====================== .. py:module:: microcontroller .. autoapi-nested-parse:: Pin references and cpu functionality The `microcontroller` module defines the pins from the perspective of the microcontroller. See `board` for board-specific pin mappings. .. data:: cpu :annotation: :Processor CPU information and control, such as ``cpu.temperature`` and ``cpu.frequency`` (clock frequency). This object is the sole instance of `microcontroller.Processor`. .. function:: delay_us(delay: int) -> None Dedicated delay method used for very short delays. **Do not** do long delays because this stops all other functions from completing. Think of this as an empty ``while`` loop that runs for the specified ``(delay)`` time. If you have other code or peripherals (e.g audio recording) that require specific timing or processing while you are waiting, explore a different avenue such as using `time.sleep()`. .. function:: disable_interrupts() -> None Disable all interrupts. Be very careful, this can stall everything. .. function:: enable_interrupts() -> None Enable the interrupts that were enabled at the last disable. .. function:: on_next_reset(run_mode: microcontroller.RunMode) -> None Configure the run mode used the next time the microcontroller is reset but not powered down. :param ~microcontroller.RunMode run_mode: The next run mode .. function:: reset() -> None Reset the microcontroller. After reset, the microcontroller will enter the run mode last set by `on_next_reset`. .. warning:: This may result in file system corruption when connected to a host computer. Be very careful when calling this! Make sure the device "Safely removed" on Windows or "ejected" on Mac OSX and Linux. .. data:: nvm :annotation: :Optional[ByteArray] Available non-volatile memory. This object is the sole instance of `nvm.ByteArray` when available or ``None`` otherwise. :type: nvm.ByteArray or None .. data:: watchdog :annotation: :Optional[WatchDogTimer] Available watchdog timer. This object is the sole instance of `watchdog.WatchDogTimer` when available or ``None`` otherwise. .. py:class:: Pin Identifies an IO pin on the microcontroller. Identifies an IO pin on the microcontroller. They are fixed by the hardware so they cannot be constructed on demand. Instead, use :mod:`board` or :mod:`microcontroller.pin` to reference the desired pin. .. py:class:: Processor Microcontroller CPU information and control Usage:: import microcontroller print(microcontroller.cpu.frequency) print(microcontroller.cpu.temperature) You cannot create an instance of `microcontroller.Processor`. Use `microcontroller.cpu` to access the sole instance available. .. attribute:: frequency :annotation: :int The CPU operating frequency in Hertz. (read-only) .. attribute:: temperature :annotation: :Optional[float] The on-chip temperature, in Celsius, as a float. (read-only) Is `None` if the temperature is not available. .. attribute:: uid :annotation: :bytearray The unique id (aka serial number) of the chip as a `bytearray`. (read-only) .. attribute:: voltage :annotation: :Optional[float] The input voltage to the microcontroller, as a float. (read-only) Is `None` if the voltage is not available. .. py:class:: RunMode run state of the microcontroller Enum-like class to define the run mode of the microcontroller and CircuitPython. .. attribute:: NORMAL :annotation: :RunMode Run CircuitPython as normal. :type microcontroller.RunMode: .. attribute:: SAFE_MODE :annotation: :RunMode Run CircuitPython in safe mode. User code will not be run and the file system will be writeable over USB. :type microcontroller.RunMode: .. attribute:: BOOTLOADER :annotation: :RunMode Run the bootloader. :type microcontroller.RunMode: