main.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2023 Daniele Lacamera <root@danielinux.net>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "unicore-mx/cm3/systick.h"
  18. #include <unicore-mx/stm32/gpio.h>
  19. #include <unicore-mx/cm3/nvic.h>
  20. #include <stdlib.h>
  21. #include <stdint.h>
  22. #include "system.h"
  23. #include "systick.h"
  24. #include "button.h"
  25. #include "stm32f7_ltdc.h"
  26. #include "ui.h"
  27. #include "timer.h"
  28. #include "led.h"
  29. #include "adc.h"
  30. #include "unicore-mx/stm32/rcc.h"
  31. #define SCB_CPACR *((volatile uint32_t *)(0xE000ED88))
  32. void sdram_init(void);
  33. void logging_setup(void);
  34. void kspserial_setup(void);
  35. void main_deck_setup(void);
  36. extern int f7_mpu_enable(void);
  37. static void fpu_init(void)
  38. {
  39. SCB_CPACR |= (0x3 << 20) | (0x03 << 22);
  40. }
  41. void hardware_setup(void)
  42. {
  43. f7_mpu_enable();
  44. fpu_init();
  45. rcc_clock_setup_hse_3v3(&rcc_hse_25mhz_3v3);
  46. nvic_set_priority(NVIC_SYSTICK_IRQ, 0);
  47. systick_enable();
  48. rcc_periph_clock_enable(RCC_TIM2);
  49. rcc_periph_clock_enable(RCC_I2C1);
  50. sdram_init();
  51. uled_init();
  52. ltdc_init();
  53. ltdc_blank();
  54. ft5336_Init(TS_I2C_ADDR);
  55. touchscreen_enable();
  56. }
  57. void main(void) {
  58. int i;
  59. uint8_t zeros[16] = {0};
  60. hardware_setup();
  61. while (jiffies < 800) {
  62. WFI();
  63. }
  64. for (i = 0; i < 6; i++)
  65. uled_off(i);
  66. ui_setup();
  67. input_setup();
  68. main_deck_setup();
  69. kspserial_setup();
  70. main_loop();
  71. }