Beispiel #1
0
/* SWI Dispatcher
 *
 * Dispatches the SWI interrupt requests.
 */
void interrupts_dispatch_swi(struct interrupts_stack_frame *stack_frame, int32_t swi_number) {
  ASSERT(interrupts_get_level() == INTERRUPTS_OFF);
  ASSERT(!interrupts_context());

  unsigned short green = 0x7E0;
  int32_t foreColour = GetForeColour();
  SetForeColour(green);
  printf("\nInterrupt SWI handler: #%d", swi_number);
  SetForeColour(foreColour);
}
Beispiel #2
0
/* IRQ Dispatcher
 *
 * Dispatches the IRQ interrupt requests. Every time that an interrupt happens, a bit that refers
 * to the specify interrupt number is marked in the interrupts register indicating that that
 * interrupt was triggered.
 * */
void interrupts_dispatch_irq(struct interrupts_stack_frame *stack_frame) {;
  unsigned short blue = 0x1f;
  int32_t foreColour = GetForeColour();
  SetForeColour(blue);
//  printf("\nKERNEL TAKING OVER - Dispatching IRQ");

  /* External interrupts are special.
     We only handle one at a time (so interrupts must be off).
     An external interrupt handler cannot sleep.
   */
  ASSERT(interrupts_get_level() == INTERRUPTS_OFF);
  ASSERT(!interrupts_context());
  ASSERT(!interrupts_was_irq_generated());

  was_irq_generated = true;
  in_external_interrupt = true; /* In external interrupt context. */
  yield_on_return = false;

  int32_t i;
  // First half of the pending interrupts (0-31)
  int32_t *interrupt_ptr = (int32_t *) INTERRUPT_REGISTER_PENDING_IRQ_0_31;
  for (i = 0; i < IRQ_COUNT / 2; i++) {
      bool enable = *interrupt_ptr & (1 << i);
      if (enable) {
          interrupts_dispatch_pending_irq(stack_frame, i);
      }
  }

  // Second half of the pending interrupts (32-63)
  interrupt_ptr = (int32_t *) INTERRUPT_REGISTER_PENDING_IRQ_32_63;
  for (i = 0; i < IRQ_COUNT / 2; i++) {
      bool enable = *interrupt_ptr & (1 << i);
      if (enable) {
          interrupts_dispatch_pending_irq(stack_frame, i);
      }
  }

  SetForeColour(foreColour);

  ASSERT(interrupts_get_level() == INTERRUPTS_OFF);
  ASSERT(interrupts_context());

  in_external_interrupt = false; /* End of the interrupt context. */
  if (yield_on_return)
    thread_yield();

  was_irq_generated = false;
}
Beispiel #3
0
void SetControlForeColor ( int iControlID, int iRed, int iGreen, int iBlue )
{
	// set control foreground colour
	SetForeColour ( iControlID, RGB ( iRed, iGreen, iBlue ) );
}
Beispiel #4
0
int main()
{
	volatile uint32_T* systimer_clo = (volatile uint32_T*) SYSTIM_CLO; 
	volatile uint32_T* systimer_cs = (volatile uint32_T*) SYSTIM_CS;
	uint32_T* systimer_c1 = (uint32_T*) SYSTIM_C1;	
	uint32_T* irq_enable1 = (uint32_T*) IRQ_ENABLE1;
	uint32_T* gpiocntrl = (uint32_T*) GPFSEL1;
	uint32_T* gpioclear = (uint32_T*) GPCLR0;
	
	FrameBufferInfo_T* fbInfoAddr;

	uint32_T* tag_cmdline;
	
	uint32_T ii;
	uint8_T output[] = "Test Eins\n\t1 23 45";
	
	// Set gpio 16 to output
	*gpiocntrl = 1<<18;
	
	// Activate system timer c1
	*systimer_c1 = *systimer_clo + TIME_TICK;
	*systimer_cs = 0x2;
	// Enable Interrupts for system timer c1
	*irq_enable1 = 0x2; 

	// Initialise Frame Buffer
	fbInfoAddr = InitialiseFrameBuffer(XW, YW, 16);	
	
	if (fbInfoAddr == NULL)
	{	
		// signal error by lighting ACT and stopping
		*gpioclear = 1<<16;
		while(1);
	}
	
	SetGraphicsAddress(fbInfoAddr);

	SetForeColour(0xffff);
	DrawLine(0,0,XW-1,0);
	DrawLine(0,10,XW-1,10);
	clearScreen();
	
	for (ii = 0; ii < 26; ii++)
		DrawCharacter(0x41+ii, ii*8, 0);				
	for (ii = 0; ii < 26; ii++)
		DrawCharacter(0x41+ii, 4 + ii*8, 16);				

	DrawLine(0,50,XW-1,30);
	
	DrawString(output, 17, 20, YW/2);
	
	clearScreen();
	
	// Find cmdline tag
	tag_cmdline = FindTag(9);
	DrawString((uint8_T*)(tag_cmdline+2), (*tag_cmdline) - 2, 0, 0);
	
	// Enable Interrupts on ARM
	ENABLE_IRQ;

	// wait until sytick reaches 5 ms
	while(systick < 5000000/TIME_TICK);
	
	while(1) {
		uint16_T x;
		uint16_T y;
		uint16_T x_old;
		uint16_T y_old;
		uint32_T colour;
		uint32_T error;
		uint32_T message[QUEUE_DIM];
		
		if (readQueue(0, message)) {
			x = message[0] % XW;		// time in ms: 1ms is 1 px, wrapped around screen width
			y = message[1];
			if (x > x_old) {
				DrawLine(x_old, y_old, x, y);
			} else {
				clearScreen();
				SetForeColour(colour);
				colour--;
				for (ii = 0; ii < 64; ii++)
					DrawCharacter(0x41+ii, ii*8, 0);				
			}

			x_old = x;
			y_old = y;	
		}

	};
	return 1;
}