llvm-mos-sdk
system.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Adrian "asie" Siekierka
3  *
4  * Licensed under the Apache License, Version 2.0 with LLVM Exceptions,
5  * See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
6  * information.
7  */
8 
9 #ifndef _PCE_SYSTEM_H_
10 #define _PCE_SYSTEM_H_
11 
12 #include <stdbool.h>
13 #include <stdint.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
23 #define NTSC_COLORBURST_FREQ (315 * 1000000 / 88)
24 #define PCE_SYSTEM_FREQ (NTSC_COLORBURST_FREQ * 6)
25 #define PCE_CPU_FREQ (NTSC_COLORBURST_FREQ * 2)
26 #define PCE_TIMER_FREQ (PCE_CPU_FREQ / 1024)
27 
36 void pce_irq_enable(uint8_t mask);
37 
43 void pce_irq_disable(uint8_t mask);
44 
48 #define PCE_FREQ_TO_TIMER(freq) ((PCE_TIMER_FREQ / (freq)) - 1)
49 
61 
65 void pce_timer_enable(void);
66 
70 void pce_timer_disable(void);
71 
75 static inline void pce_cpu_irq_enable() {
76  __attribute__((leaf)) asm volatile("cli\n");
77 }
78 
82 static inline void pce_cpu_irq_disable() {
83  __attribute__((leaf)) asm volatile("sei\n");
84 }
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif /* _PCE_SYSTEM_H_ */
pce_irq_enable
void pce_irq_enable(uint8_t mask)
Enable the specified IRQs.
pce_irq_disable
void pce_irq_disable(uint8_t mask)
Disable the specified IRQs.
std::uint8_t
::uint8_t uint8_t
Definition: cstdint:21
count
const void uint16_t count
Definition: memory.h:58
pce_timer_disable
void pce_timer_disable(void)
Disable the timer.
pce_timer_enable
void pce_timer_enable(void)
Enable the timer.
pce_timer_set
void pce_timer_set(uint8_t count)
Initialize the timer with a given reload value.