| #include <inttypes.h> |
| #include <assert.h> |
| #include "syscfg/syscfg.h" |
| #include "sysflash/sysflash.h" |
| #include "hal/hal_system.h" |
| #include "hal/hal_flash_int.h" |
| #include "hal/hal_timer.h" |
| #include "hal/hal_bsp.h" |
| #include "os/os.h" |
| #include "bsp/bsp.h" |
| |
| /** What memory to include in coredump. */ |
| static const struct hal_bsp_mem_dump dump_cfg[] = { |
| [0] = { |
| .hbmd_start = &_ram_start, |
| .hbmd_size = RAM_SIZE, |
| } |
| }; |
| |
| const struct hal_bsp_mem_dump * |
| hal_bsp_core_dump(int *area_cnt) |
| { |
| *area_cnt = sizeof(dump_cfg) / sizeof(dump_cfg[0]); |
| return dump_cfg; |
| } |
| |
| /** |
| * Retrieves the flash device with the specified ID. Returns NULL if no such |
| * device exists. |
| */ |
| const struct hal_flash * |
| hal_bsp_flash_dev(uint8_t id) |
| { |
| switch (id) { |
| case 0: |
| /* MCU internal flash. */ |
| /* XXX: Return pointer to MCU's flash object. */ |
| return NULL; |
| |
| default: |
| /* External flash. Assume not present in this BSP. */ |
| return NULL; |
| } |
| } |
| |
| /** |
| * Retrieves the configured priority for the given interrupt. If no priority |
| * is configured, returns the priority passed in. |
| * |
| * @param irq_num The IRQ being queried. |
| * @param pri The default priority if none is configured. |
| * |
| * @return uint32_t The specified IRQ's priority. |
| */ |
| uint32_t |
| hal_bsp_get_nvic_priority(int irq_num, uint32_t pri) |
| { |
| return pri; |
| } |
| |
| void |
| hal_bsp_init(void) |
| { |
| int rc; |
| |
| (void)rc; |
| |
| /* Make sure system clocks have started. */ |
| hal_system_clock_start(); |
| |
| #if MYNEWT_VAL(TIMER_0) |
| rc = hal_timer_init(0, NULL); |
| assert(rc == 0); |
| #endif |
| |
| #if (MYNEWT_VAL(OS_CPUTIME_TIMER_NUM) >= 0) |
| rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQ)); |
| assert(rc == 0); |
| #endif |
| |
| /* Initialize additional BSP peripherals here. */ |
| } |