Beispiel #1
0
/** print %d and %i */
static void
print_num_d(char **at, size_t * left, int *ret, int value,
	    int minw, int precision, int prgiven, int zeropad, int minus,
	    int plus, int space)
{
    char buf[PRINT_DEC_BUFSZ];
    int negative = (value < 0);
    int zero = (value == 0);
    int len = print_dec(buf, (int)sizeof(buf),
			(unsigned int)(negative ? -value : value));
    print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
	      plus, space, zero, negative, buf, len);
}
Beispiel #2
0
void printPacket(MRF_packet_t *rx_packet)
{
    // Print a label for the packet type
    switch (rx_packet->type) {
        case PACKET_TYPE_SERIAL:
            sendStringP(typeSerialString);
            break;
        case PACKET_TYPE_SERIAL_ECC:
            sendStringP(typeSerialECCString);
            break;
        case PACKET_TYPE_PACKET:
            sendStringP(typePacketString);
            break;
        case PACKET_TYPE_PACKET_ECC:
            sendStringP(typePacketECCString);
            break;
        default:
            sendStringP(typeUnknownString);
            break;
    }
    
    // Print the packet length
    sendStringP(packetLengthString);
    print_dec(rx_packet->payloadSize);
    CDC_Device_SendByte(&CDC_interface, ':');
    CDC_Device_SendByte(&CDC_interface, ' ');
    
    // Print the packet contents
    for (int i = 0; i < rx_packet->payloadSize; i++) {
        if (i % 10 == 0) {
            CDC_Device_SendByte(&CDC_interface, '\n');
            CDC_Device_SendByte(&CDC_interface, '\r');
        }
        
        uint8_t byte = rx_packet->payload[i];
        CDC_Device_SendByte(&CDC_interface, byte);
//        if (byte & 0xF0 > 0x90) {
//            CDC_Device_SendByte(&CDC_interface, ((byte & 0xF0) >> 4) + 'A');
//        } else {
//            CDC_Device_SendByte(&CDC_interface, ((byte & 0xF0) >> 4) + '0');
//        }
//        
//        if (byte & 0x0F > 0x09) {
//            CDC_Device_SendByte(&CDC_interface, (byte & 0x0F) + 'A');
//        } else {
//            CDC_Device_SendByte(&CDC_interface, (byte & 0x0F) + '0');
//        }
    }
    
    CDC_Device_Flush(&CDC_interface);
}
Beispiel #3
0
extern void panic(const char *message, const char *file, u32int line)
{
    // We encountered a massive problem and have to stop.
    asm volatile("cli"); // Disable interrupts.

    print("PANIC(");
    print((char*)message);
    print(") at ");
    print((char*)file);
    print(":");
    print_dec(line);
    print("\n");
    // Halt by going into an infinite loop.
    for(;;);
}
Beispiel #4
0
/*
 * helper functions to print instructions
 */
void print_fop(struct filter_op *fop, u_int32 eip)
{
      switch (fop->opcode) {
         case FOP_TEST:
            print_test(fop, eip);
            break;
            
         case FOP_ASSIGN:
            print_assign(fop, eip);
            break;
            
         case FOP_INC:
            print_inc(fop, eip);
            break;
            
         case FOP_DEC:
            print_dec(fop, eip);
            break;
            
         case FOP_FUNC:
            print_function(fop, eip);
            break;
            
         case FOP_JMP:
            fprintf(stdout, "%04lu: JUMP ALWAYS to %04d\n", (unsigned long)eip, fop->op.jmp);
            break;
            
         case FOP_JTRUE:
            fprintf(stdout, "%04lu: JUMP IF TRUE to %04d\n", (unsigned long)eip, fop->op.jmp);
            break;
            
         case FOP_JFALSE:
            fprintf(stdout, "%04lu: JUMP IF FALSE to %04d\n", (unsigned long)eip, fop->op.jmp);
            break;
            
         case FOP_EXIT:
            fprintf(stdout, "%04lu: EXIT\n", (unsigned long)eip);
            break;
            
         default:
            fprintf(stderr, "UNDEFINED OPCODE (%d) !!\n", fop->opcode);
            exit(-1);
            break;
      }
}
Beispiel #5
0
//=============================================================================
void lcd_edit_date(void)
{
  LCD_goto(0, 0);
  LCD_puts(optionmenu[o_menu]);
  if (n_edit_date == 0)
  {
    LCD_goto(9, 0);
    LCD_puts(" [DAY]");
    LCD_goto(0, 1);
	if (blinks == 1) print_dec(day, 2, '0'); else { LCD_dat(' '); LCD_dat(' '); }
    LCD_dat('-');
    print_dec(mes, 2, '0');
    LCD_dat('-');
    print_dec(2000 + year, 4, '0');
    LCD_dat(' '); LCD_dat('['); LCD_puts(den_dw[wday]); LCD_dat(']');
  } else if (n_edit_date == 1) {
    LCD_goto(9, 0);
    LCD_puts(" [MES] ");
    LCD_goto(0, 1);
    print_dec(day, 2, '0');
    LCD_dat('-');
	if (blinks == 1) print_dec(mes, 2, '0'); else { LCD_dat(' '); LCD_dat(' '); }
    LCD_dat('-');
    print_dec(2000 + year, 4, '0');
    LCD_dat(' '); LCD_dat('['); LCD_puts(den_dw[wday]); LCD_dat(']');
  } else if (n_edit_date == 2) {
    LCD_goto(9, 0);
    LCD_puts(" [YEAH]");
    LCD_goto(0, 1);
    print_dec(day, 2, '0');
    LCD_dat('-');
    print_dec(mes, 2, '0');
    LCD_dat('-');
	if (blinks == 1) { print_dec(2000 + year, 4, '0'); } else { LCD_puts("    "); }
    LCD_dat(' '); LCD_dat('['); LCD_puts(den_dw[wday]); LCD_dat(']');
  }
}
Beispiel #6
0
static int dump_msft_typeinfo(int n)
{
    int i;

    print_begin_block_id("TypeInfo", n);

    if((msft_typeinfo_kind[n] & 0xf) == TKIND_COCLASS) {
        dump_msft_coclass(n);
        print_end_block();
        return -1;
    }

    print_dec("size");

    for(i = 0; i < LOWORD(msft_typeinfo_elemcnt[n]); i++)
        dump_msft_func(i);

    for(i = 0; i < HIWORD(msft_typeinfo_elemcnt[n]); i++)
        dump_msft_var(i);

    for(i = 0; i < LOWORD(msft_typeinfo_elemcnt[n]); i++)
        print_hex_id("func %d id", i);

    for(i = 0; i < HIWORD(msft_typeinfo_elemcnt[n]); i++)
        print_hex_id("var %d id", i);

    for(i = 0; i < LOWORD(msft_typeinfo_elemcnt[n]); i++)
        print_hex_id("func %d name", i);

    for(i = 0; i < HIWORD(msft_typeinfo_elemcnt[n]); i++)
        print_hex_id("var %d name", i);

    for(i = 0; i < LOWORD(msft_typeinfo_elemcnt[n]); i++)
        print_hex_id("func %d offset", i);

    for(i = 0; i < HIWORD(msft_typeinfo_elemcnt[n]); i++)
        print_hex_id("var %d offset", i);

    print_end_block();

    return -1;
}
Beispiel #7
0
//=============================================================================
void lcd_edit_alarm(void)
{
  LCD_goto(0, 0);
  LCD_puts(optionmenu[o_menu]);
  if (n_edit_alarm == 1)
  {
    LCD_goto(9, 0);
    LCD_puts(" [HOUR]");
    LCD_goto(0, 1);
	if (blinks == 1) print_dec(a_hour, 2, '0'); else { LCD_dat(' '); LCD_dat(' '); }
    LCD_dat(':');
    print_dec(a_min, 2, '0');
    LCD_dat(':');
    LCD_dat('0'); LCD_dat('0');
    LCD_dat(' '); LCD_dat('-'); LCD_dat(' '); LCD_dat('[');
    if (a_onoff == 1) LCD_puts(" ON"); else LCD_puts("OFF");
    LCD_dat(']');
  } else if (n_edit_alarm == 2) {
    LCD_goto(9, 0);
    LCD_puts(" [MIN] ");
    LCD_goto(0, 1);
    print_dec(a_hour, 2, '0');
    LCD_dat(':');
	if (blinks == 1) print_dec(a_min, 2, '0'); else { LCD_dat(' '); LCD_dat(' '); }
    LCD_dat(':');
    LCD_dat('0'); LCD_dat('0');
    LCD_dat(' '); LCD_dat('-'); LCD_dat(' '); LCD_dat('[');
    if (a_onoff == 1) LCD_puts(" ON"); else LCD_puts("OFF");
    LCD_dat(']');
  } else if (n_edit_alarm == 0) {
    LCD_goto(9, 0);
    LCD_puts(" [MOD] ");
    LCD_goto(0, 1);
    print_dec(a_hour, 2, '0');
    LCD_dat(':');
    print_dec(a_min, 2, '0');
    LCD_dat(':');
    LCD_dat('0'); LCD_dat('0');
    LCD_dat(' '); LCD_dat('-'); LCD_dat(' '); LCD_dat('[');
    if (blinks == 1) {
      if (a_onoff == 1) LCD_puts(" ON"); else LCD_puts("OFF");
    } else {
      LCD_puts("   ");
    }
    LCD_dat(']');
  }
}
Beispiel #8
0
uint game_pirata_inicializar(uint type, uint jugador, uint opcional_pos)
{
	jugador_t* jugador_actual = game_obtener_jugador(jugador);
	uint i = game_obtener_posicion_pirata_disponible(jugador_actual);
	
	if ( i < 8 ) {
		jugador_actual->piratas[i].pos   = jugador_actual->piratas[i].jugador->pos_puerto;
		jugador_actual->piratas[i].type  = type;
		jugador_actual->piratas[i].clock = 0; 
		jugador_actual->piratas[i].id	 = i + (jugador * 8);
		game_jugador_erigir_pirata(jugador, &jugador_actual->piratas[i], i, opcional_pos);
		agregar_posiciones_mapeadas(&jugador_actual->piratas[i]);
		return jugador_actual->piratas[i].id;
	} else {
		if (type == PIRATA_MINERO) {
			i = game_obtener_posicion_minero_disponible(jugador_actual);
			jugador_actual->mineros_pendientes[i].id = 1;
			jugador_actual->mineros_pendientes[i].posDestino = opcional_pos;
			print_dec(i, 3, 30, 45, 0x2);
		}
	}
	return 17;
}
Beispiel #9
0
//=============================================================================
void lcd_edit_time(void)
{
  LCD_goto(0, 0);
  LCD_puts(optionmenu[o_menu]);
  if (n_edit_time == 0)
  {
    LCD_goto(9, 0);
    LCD_puts(" [HOUR]");
    LCD_goto(0, 1);
	if (blinks == 1) print_dec(hour, 2, '0'); else { LCD_dat(' '); LCD_dat(' '); }
    LCD_dat(':'); print_dec(min, 2, '0'); LCD_dat(':'); print_dec(0, 2, '0');
  } else if (n_edit_time == 1) {
    LCD_goto(9, 0);
    LCD_puts(" [MIN] ");
    LCD_goto(0, 1); print_dec(hour, 2, '0'); LCD_dat(':');
	if (blinks == 1) print_dec(min, 2, '0'); else { LCD_dat(' '); LCD_dat(' '); }
    LCD_dat(':'); print_dec(0, 2, '0');
  }
}
Beispiel #10
0
void
print_node_brief (FILE *file, const char *prefix, const_tree node, int indent)
{
    enum tree_code_class tclass;

    if (node == 0)
        return;

    tclass = TREE_CODE_CLASS (TREE_CODE (node));

    /* Always print the slot this node is in, and its code, address and
       name if any.  */
    if (indent > 0)
        fprintf (file, " ");
    fprintf (file, "%s <%s", prefix, get_tree_code_name (TREE_CODE (node)));
    dump_addr (file, " ", node);

    if (tclass == tcc_declaration)
    {
        if (DECL_NAME (node))
            fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
        else if (TREE_CODE (node) == LABEL_DECL
                 && LABEL_DECL_UID (node) != -1)
        {
            if (dump_flags & TDF_NOUID)
                fprintf (file, " L.xxxx");
            else
                fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
        }
        else
        {
            if (dump_flags & TDF_NOUID)
                fprintf (file, " %c.xxxx",
                         TREE_CODE (node) == CONST_DECL ? 'C' : 'D');
            else
                fprintf (file, " %c.%u",
                         TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
                         DECL_UID (node));
        }
    }
    else if (tclass == tcc_type)
    {
        if (TYPE_NAME (node))
        {
            if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
                fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
            else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
                     && DECL_NAME (TYPE_NAME (node)))
                fprintf (file, " %s",
                         IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
        }
        if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
            fprintf (file, " address-space-%d", TYPE_ADDR_SPACE (node));
    }
    if (TREE_CODE (node) == IDENTIFIER_NODE)
        fprintf (file, " %s", IDENTIFIER_POINTER (node));

    /* We might as well always print the value of an integer or real.  */
    if (TREE_CODE (node) == INTEGER_CST)
    {
        if (TREE_OVERFLOW (node))
            fprintf (file, " overflow");

        fprintf (file, " ");
        print_dec (node, file, TYPE_SIGN (TREE_TYPE (node)));
    }
    if (TREE_CODE (node) == REAL_CST)
    {
        REAL_VALUE_TYPE d;

        if (TREE_OVERFLOW (node))
            fprintf (file, " overflow");

        d = TREE_REAL_CST (node);
        if (REAL_VALUE_ISINF (d))
            fprintf (file,  REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
        else if (REAL_VALUE_ISNAN (d))
            fprintf (file, " Nan");
        else
        {
            char string[60];
            real_to_decimal (string, &d, sizeof (string), 0, 1);
            fprintf (file, " %s", string);
        }
    }
    if (TREE_CODE (node) == FIXED_CST)
    {
        FIXED_VALUE_TYPE f;
        char string[60];

        if (TREE_OVERFLOW (node))
            fprintf (file, " overflow");

        f = TREE_FIXED_CST (node);
        fixed_to_decimal (string, &f, sizeof (string));
        fprintf (file, " %s", string);
    }

    fprintf (file, ">");
}
Beispiel #11
0
static void print_eeconfig(void)
{
    print("default_layer: "); print_dec(eeconfig_read_default_layer()); print("\n");

    debug_config_t dc;
    dc.raw = eeconfig_read_debug();
    print("debug_config.raw: "); print_hex8(dc.raw); print("\n");
    print(".enable: "); print_dec(dc.enable); print("\n");
    print(".matrix: "); print_dec(dc.matrix); print("\n");
    print(".keyboard: "); print_dec(dc.keyboard); print("\n");
    print(".mouse: "); print_dec(dc.mouse); print("\n");

    keymap_config_t kc;
    kc.raw = eeconfig_read_keymap();
    print("keymap_config.raw: "); print_hex8(kc.raw); print("\n");
    print(".swap_control_capslock: "); print_dec(kc.swap_control_capslock); print("\n");
    print(".capslock_to_control: "); print_dec(kc.capslock_to_control); print("\n");
    print(".swap_lalt_lgui: "); print_dec(kc.swap_lalt_lgui); print("\n");
    print(".swap_ralt_rgui: "); print_dec(kc.swap_ralt_rgui); print("\n");
    print(".no_gui: "); print_dec(kc.no_gui); print("\n");
    print(".swap_grave_esc: "); print_dec(kc.swap_grave_esc); print("\n");
    print(".swap_backslash_backspace: "); print_dec(kc.swap_backslash_backspace); print("\n");

#ifdef BACKLIGHT_ENABLE
    backlight_config_t bc;
    bc.raw = eeconfig_read_backlight();
    print("backlight_config.raw: "); print_hex8(bc.raw); print("\n");
    print(".enable: "); print_dec(bc.enable); print("\n");
    print(".level: "); print_dec(bc.level); print("\n");
#endif
}
Beispiel #12
0
static void print_eeconfig(void)
{

// Print these variables if NO_PRINT or USER_PRINT are not defined.
#if !defined(NO_PRINT) && !defined(USER_PRINT)

    print("default_layer: "); print_dec(eeconfig_read_default_layer()); print("\n");

    debug_config_t dc;
    dc.raw = eeconfig_read_debug();
    print("debug_config.raw: "); print_hex8(dc.raw); print("\n");
    print(".enable: "); print_dec(dc.enable); print("\n");
    print(".matrix: "); print_dec(dc.matrix); print("\n");
    print(".keyboard: "); print_dec(dc.keyboard); print("\n");
    print(".mouse: "); print_dec(dc.mouse); print("\n");

    keymap_config_t kc;
    kc.raw = eeconfig_read_keymap();
    print("keymap_config.raw: "); print_hex8(kc.raw); print("\n");
    print(".swap_control_capslock: "); print_dec(kc.swap_control_capslock); print("\n");
    print(".capslock_to_control: "); print_dec(kc.capslock_to_control); print("\n");
    print(".swap_lalt_lgui: "); print_dec(kc.swap_lalt_lgui); print("\n");
    print(".swap_ralt_rgui: "); print_dec(kc.swap_ralt_rgui); print("\n");
    print(".no_gui: "); print_dec(kc.no_gui); print("\n");
    print(".swap_grave_esc: "); print_dec(kc.swap_grave_esc); print("\n");
    print(".swap_backslash_backspace: "); print_dec(kc.swap_backslash_backspace); print("\n");
    print(".nkro: "); print_dec(kc.nkro); print("\n");

#ifdef BACKLIGHT_ENABLE
    backlight_config_t bc;
    bc.raw = eeconfig_read_backlight();
    print("backlight_config.raw: "); print_hex8(bc.raw); print("\n");
    print(".enable: "); print_dec(bc.enable); print("\n");
    print(".level: "); print_dec(bc.level); print("\n");
#endif /* BACKLIGHT_ENABLE */

#endif /* !NO_PRINT */

}
Beispiel #13
0
uint32_t *irq(uint32_t *regs, uint32_t irqs)
{
	static unsigned int ext_irq_4_count = 0;
	static unsigned int ext_irq_5_count = 0;
	static unsigned int timer_irq_count = 0;

	if ((irqs & (1<<4)) != 0) {
		ext_irq_4_count++;
		// print_str("[EXT-IRQ-4]");
	}

	if ((irqs & (1<<5)) != 0) {
		ext_irq_5_count++;
		// print_str("[EXT-IRQ-5]");
	}

	if ((irqs & 1) != 0) {
		timer_irq_count++;
		// print_str("[TIMER-IRQ]");
	}

	if ((irqs & 6) != 0)
	{
		uint32_t pc = regs[0] - 4;
		uint16_t *instr_hwords = (uint16_t*)pc;
		uint32_t instr = instr_hwords[0] | (instr_hwords[1] << 16);

		print_str("\n");
		print_str("------------------------------------------------------------\n");

		if ((irqs & 2) != 0) {
			if (instr == 0x00100073 || (instr & 0xffff) == 9002) {
				print_str("SBREAK instruction at 0x");
				print_hex(pc, 8);
				print_str("\n");
			} else {
				print_str("Illegal Instruction at 0x");
				print_hex(pc, 8);
				print_str(": 0x");
				print_hex(instr, ((instr & 3) == 3) ? 8 : 4);
				print_str("\n");
			}
		}

		if ((irqs & 4) != 0) {
			print_str("Bus error in Instruction at 0x");
			print_hex(pc, 8);
			print_str(": 0x");
			print_hex(instr, ((instr & 3) == 3) ? 8 : 4);
			print_str("\n");
		}

		for (int i = 0; i < 8; i++)
		for (int k = 0; k < 4; k++)
		{
			int r = i + k*8;

			if (r == 0) {
				print_str("pc  ");
			} else
			if (r < 10) {
				print_chr('x');
				print_chr('0' + r);
				print_chr(' ');
				print_chr(' ');
			} else
			if (r < 20) {
				print_chr('x');
				print_chr('1');
				print_chr('0' + r - 10);
				print_chr(' ');
			} else
			if (r < 30) {
				print_chr('x');
				print_chr('2');
				print_chr('0' + r - 20);
				print_chr(' ');
			} else {
				print_chr('x');
				print_chr('3');
				print_chr('0' + r - 30);
				print_chr(' ');
			}

			print_hex(regs[r], 8);
			print_str(k == 3 ? "\n" : "    ");
		}

		print_str("------------------------------------------------------------\n");

		print_str("Number of fast external IRQs counted: ");
		print_dec(ext_irq_4_count);
		print_str("\n");

		print_str("Number of slow external IRQs counted: ");
		print_dec(ext_irq_5_count);
		print_str("\n");

		print_str("Number of timer IRQs counted: ");
		print_dec(timer_irq_count);
		print_str("\n");

		__asm__ volatile ("sbreak");
	}
Beispiel #14
0
int main(void) {
    uint8_t byte;
    
    // Initalize the system
    init();
    
    // Load the saved registers
    applySavedRegisters();
    MRF_reset();
    
    // Get the default boot state
    mode = getBootState();
    
    // Loop here forever
    while (true) {
        
        // Process menu actions as long as we're in the menu or test modes
        // New packets received while in menu mode are ignored
        if (mode == MENU      ||
            mode == TEST_ALT  ||
            mode == TEST_ZERO ||
            mode == TEST_ONE  ||
            mode == CAPTURE   ||
            mode == TEST_PING ) {

            // Handle any new bytes from the USB system
            // These functions can be assumed to return immediately.
            if (CDC_Device_BytesReceived(&CDC_interface) > 0) {
                byte = CDC_Device_ReceiveByte(&CDC_interface);

                menuHandleByte(byte);
            }
            
            // Test for a new packet
            MRF_packet_t *rx_packet = MRF_receive_packet();

            // Was the packet correctly received?
            if (rx_packet  != NULL) {
                switch (mode) {
                    case TEST_PING:
                        MRF_transmit_packet(rx_packet);
                        sendStringP(pingString);
                        printPacket(rx_packet);
                        break;
                    case CAPTURE:
                        printPacket(rx_packet);
                        break;
                    default:
                        // Other menu modes would end up here, ignore the packet
                        break;
                }
            }
        }
        
        // These modes are responsible for actually using the RF interface
        else {
            switch (mode) {
                case PACKET:
                case PACKET_ECC:
                    packetMainLoop();
                    break;
                    
                case SERIAL:
                case SERIAL_ECC:
                    serialMainLoop();
                    break;
                    
                case USB_SERIAL:
                    usbSerialMainLoop();
                    break;
                    
                default:
                    // This would catch any weird modes
                    sendStringP(invalidModeString);
                    print_dec(mode);
                    CDC_Device_Flush(&CDC_interface);
                    mode = MENU;
                    break;
            }
        }
    }
}
Beispiel #15
0
void screen_pintar_puntajes()
{
    print_dec(jugadorA.puntos, 3, 33+2, 45+2, C_BG_RED  | C_FG_WHITE);
    print_dec(jugadorB.puntos, 3, 40+2, 45+2, C_BG_BLUE | C_FG_WHITE);
}