12 #include <satcat5/cfgbus_interrupt.h>
22 namespace log = satcat5::log;
25 #ifndef SATCAT5_CHECK_DUPIRQ
26 #define SATCAT5_CHECK_DUPIRQ 1
29 WrappedRegister::WrappedRegister(
ConfigBus* cfg,
unsigned reg)
36 WrappedRegister::operator u32()
39 m_cfg->read(m_reg, tmp);
43 void WrappedRegister::operator=(u32 wrval)
45 m_cfg->
write(m_reg, wrval);
48 void WrappedRegister::write_repeat(
unsigned count,
const u32* data)
53 WrappedRegisterPtr::WrappedRegisterPtr(
ConfigBus* cfg,
unsigned reg)
60 bool WrappedRegisterPtr::operator!()
const
84 if (SATCAT5_CHECK_DUPIRQ && m_irq_list.
contains(obj)) {
85 log::Log(log::ERROR,
"ConfigBus IRQ duplicate");
98 return m_irq_list.
len();
104 #if SATCAT5_CFGBUS_DIRECT
105 return (
volatile u32*)(m_base_ptr + idx);
121 ConfigBus::ConfigBus(
void* base_ptr)
122 : m_base_ptr((volatile u32*)base_ptr)
128 unsigned regaddr,
unsigned count, u32* result)
131 for (
unsigned a = 0 ; a < count ; ++a) {
133 if (tmp != IoStatus::OK) status = tmp;
139 unsigned regaddr,
unsigned count, u32* result)
142 for (
unsigned a = 0 ; a < count ; ++a) {
144 if (tmp != IoStatus::OK) status = tmp;
150 unsigned regaddr,
unsigned count,
const u32* data)
153 for (
unsigned a = 0 ; a < count ; ++a) {
155 if (tmp != IoStatus::OK) status = tmp;
161 unsigned regaddr,
unsigned count,
const u32* data)
164 for (
unsigned a = 0 ; a < count ; ++a) {
166 if (tmp != IoStatus::OK) status = tmp;
172 val = m_base_ptr[regaddr];
177 m_base_ptr[regaddr] = val;
183 , irq::Handler(
"ConfigBus", irq)
ConfigBus core definitions.
IoStatus
Status codes for ConfigBus read/write operations.
virtual satcat5::cfg::IoStatus read(unsigned regaddr, u32 &rdval)=0
Basic single-register read operation.
satcat5::cfg::Register get_register(unsigned dev, unsigned reg=0)
Create register-map object for the given device address.
void irq_poll()
Poll all registered ConfigBus interrupt handlers.
virtual satcat5::cfg::IoStatus write(unsigned regaddr, u32 wrval)=0
Basic single-register write operation.
virtual satcat5::cfg::IoStatus read_repeat(unsigned regaddr, unsigned count, u32 *result)
Bulk-read the same register N times.
unsigned get_regaddr(unsigned dev, unsigned reg) const
Convert device + register to combined address.
virtual satcat5::cfg::IoStatus write_repeat(unsigned regaddr, unsigned count, const u32 *data)
Bulk-write the same register N times.
void unregister_irq(satcat5::cfg::Interrupt *obj)
Remove an interrupt handler.
virtual satcat5::cfg::IoStatus write_array(unsigned regaddr, unsigned count, const u32 *data)
Bulk-write with auto-increment (regaddr, regaddr+1, ...)
void register_irq(satcat5::cfg::Interrupt *obj)
Add an interrupt handler.
unsigned count_irq() const
Count attached interrupt handlers.
virtual satcat5::cfg::IoStatus read_array(unsigned regaddr, unsigned count, u32 *result)
Bulk-read with auto-increment (regaddr, regaddr+1, ...) Bulk read/write operations are more efficient...
Memory-mapped local ConfigBus.
satcat5::cfg::IoStatus write(unsigned regaddr, u32 val) override
Basic single-register write operation.
void * get_device_mmap(unsigned dev) const
Get a raw pointer to the designated device-address.
void irq_event() override
Method called whenever an interrupt is triggered.
satcat5::cfg::IoStatus read(unsigned regaddr, u32 &val) override
Basic single-register read operation.
ConfigBusMmap(void *base_ptr, int irq)
Constructor accepts the base pointer for the memory-map interface, and the interrupt-index for the sh...
Event-handler for individual ConfigBus interrupts.
void irq_check()
Check if this interrupt may need service.
Generic wrapper for a specific ConfigBus register.
Pointer-like wrapper for one or more ConfigBus registers.
The Log class creates and formats one log message.
unsigned len() const
Traverse the linked list to count its length.
bool contains(const T *item) const
Scan the list, looking for the item in question.
void add(T *item)
Add new item to front or back, whichever is simpler.
void remove(T *item)
Remove the designated item from the list.
Diagnostic logging to UART and/or Ethernet ports.