Demo entry 6313161

C

   

Submitted by anonymous on Oct 25, 2016 at 22:27
Language: C. Code size: 646 Bytes.

#define IRQ_A  (1)
#define IRQ_B  (2)
#define NVIC_A (0xe000e100)
#define NVIC_B (0xe000e104)

int irqinfo(int irq, uint32_t *addr) 
{
  if (irq == IRQ_A)
    *addr = NVIC_A;    
  else if (irq == IRQ_B)
    *addr = NVIC_B;
  else
    return ERROR; /* Invalid IRQ */
  return OK;
} 

int enable_irq(int irq)
{
  uint32_t addr, val;
  if (stm32_irqinfo(irq, &addr) == OK) {
    val = *(uint32_t *)addr;
    val |= 0x1;
    *(uint32_t *)addr = val;
  }
}

#define DEV_X  (0x50000804)

void dev_reset(struct dev *priv)
{
  uint32_t val;
  val = *(uint32_t *)DEV_X;
  val &= (1 << 1);
  *(uint32_t *)DEV_X = val;
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).