interface-arm.c 609 B

1234567891011121314151617181920212223242526272829303132
  1. #include "interface.h"
  2. #include <stdint.h>
  3. #include <stdio.h>
  4. // This targets an ARM Cortex M3 core using QEmu LM3S6965 emulation.
  5. #define STBASE 0xE000E000
  6. #define STCTRL (*(volatile uint32_t*)(0x010 + STBASE))
  7. #define STRELOAD (*(volatile uint32_t*)(0x014 + STBASE))
  8. #define STCURRENT (*(volatile uint32_t*)(0x018 + STBASE))
  9. void interface_init()
  10. {
  11. STRELOAD = 0x00FFFFFF;
  12. STCTRL = 5;
  13. }
  14. void start_timing()
  15. {
  16. STCURRENT = 0;
  17. }
  18. uint16_t end_timing()
  19. {
  20. return 0x00FFFFFF - STCURRENT - 4;
  21. }
  22. void print_value(const char *label, int32_t value)
  23. {
  24. printf("%-20s %ld\n", label, value);
  25. }