Skip to content
Snippets Groups Projects
Select Git revision
  • 8cf08a58a1a429350dc7057e08b0b7e494f60fe3
  • wip-bootstrap default
  • dualcore
  • ch3/leds
  • ch3/time
  • master
6 results

modpyb.c

Blame
  • modpyb.c 9.07 KiB
    #include <stdint.h>
    #include <stdio.h>
    
    #include "stm32f4xx_hal.h"
    
    #include "misc.h"
    #include "mpconfig.h"
    #include "qstr.h"
    #include "obj.h"
    #include "gc.h"
    #include "gccollect.h"
    #include "systick.h"
    #include "pybstdio.h"
    #include "pyexec.h"
    #include "led.h"
    #include "pin.h"
    #include "extint.h"
    #include "usrsw.h"
    #include "rng.h"
    #include "rtc.h"
    #include "usart.h"
    #include "adc.h"
    #include "storage.h"
    #include "sdcard.h"
    #include "accel.h"
    #include "servo.h"
    #include "dac.h"
    #include "i2c.h"
    #include "usb.h"
    #include "modpyb.h"
    #include "ff.h"
    
    // get lots of info about the board
    STATIC mp_obj_t pyb_info(uint n_args, const mp_obj_t *args) {
        // get and print unique id; 96 bits
        {
            byte *id = (byte*)0x1fff7a10;
            printf("ID=%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x\n", id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7], id[8], id[9], id[10], id[11]);
        }
    
        // get and print clock speeds
        // SYSCLK=168MHz, HCLK=168MHz, PCLK1=42MHz, PCLK2=84MHz
        {
            printf("S=%lu\nH=%lu\nP1=%lu\nP2=%lu\n", 
                   HAL_RCC_GetSysClockFreq(),
                   HAL_RCC_GetHCLKFreq(),
                   HAL_RCC_GetPCLK1Freq(),
                   HAL_RCC_GetPCLK2Freq());
        }
    
        // to print info about memory
        {
            printf("_etext=%p\n", &_etext);
            printf("_sidata=%p\n", &_sidata);
            printf("_sdata=%p\n", &_sdata);
            printf("_edata=%p\n", &_edata);
            printf("_sbss=%p\n", &_sbss);
            printf("_ebss=%p\n", &_ebss);
            printf("_estack=%p\n", &_estack);
            printf("_ram_start=%p\n", &_ram_start);
            printf("_heap_start=%p\n", &_heap_start);
            printf("_heap_end=%p\n", &_heap_end);
            printf("_ram_end=%p\n", &_ram_end);
        }
    
        // qstr info
        {
            uint n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
            qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes);
            printf("qstr:\n  n_pool=%u\n  n_qstr=%u\n  n_str_data_bytes=%u\n  n_total_bytes=%u\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes);