Пример #1
0
unsigned int usart_putc(char c)
{
  cm_disable_interrupts();
  unsigned int next = (tx_head + 1) % sizeof(tx_buf);
  if (waiting_tx_bytes() == sizeof(tx_buf)) {
    cm_enable_interrupts();
    return 0;
  }

  tx_buf[tx_head] = c;
  tx_head = next;
  cm_enable_interrupts();
  usart_enable_tx_interrupt(USART1);
  return 1;
}
Пример #2
0
uint64_t time_get_ns() {
  uint64_t result;
  // keep calculating result until it is calculated without a rollover having
  // happened
  cm_disable_interrupts();
  do {
    result = (rollovers << 24) | (0xffffff - systick_get_value());
  } while(check_rollover());
  cm_enable_interrupts();
  return result*125/9;
}
Пример #3
0
int dbg_serial_read( unsigned char *d, unsigned short n )
{
    int res;
    res = 0;
    while( n-- )
    {
        cm_disable_interrupts();
        if( dbg_fifo_read_byte( &usart_rx_buf, d ) )
        {
            cm_enable_interrupts();
            d++;
            res++;
        }
        else
        {
            cm_enable_interrupts();
            break;
        }
    }
    return res;
}
Пример #4
0
int dbg_serial_write( unsigned char *d, unsigned short n )
{
    int res = 0;
    cm_disable_interrupts();
    res = dbg_fifo_write( &usart_tx_buf, d, n );
    if( res && !(USART_CR1(DBG_USART) & USART_CR1_TXEIE) )
    {
        if( dbg_fifo_read_byte( &usart_tx_buf, &usart_data ) )
        {
            while( !(USART_SR(DBG_USART) & USART_SR_TXE) );///пока буфер не пуст
            usart_send(DBG_USART, usart_data);
            usart_enable_tx_interrupt(DBG_USART);
        }
    }
    cm_enable_interrupts();
    return res;
}
Пример #5
0
static void drop_privs(void)
{
    if (!canDropPrivs())
        return;

    // Legacy bootloader code will have interrupts disabled at this point.
    // To maintain compatibility, the timer and button interrupts need to
    // be enabled and then global interrupts enabled. This is a nop in the
    // modern scheme.
    cm_enable_interrupts();

    // Turn on memory protection for good signature. KK firmware is signed
    mpu_config(SIG_OK);

    // set thread mode to unprivileged here. This will help protect against 0days
    __asm__ volatile("msr control, %0" :: "r" (0x3));   // unpriv thread mode using psp stack
}
Пример #6
0
int main(void)
{
	cm_disable_interrupts();
	clk_tree_setup();
	mco_setup();
	clock_setup();
	usb_setup();
	cli_setup();
	pwm_init();
	led_setup();
	button_setup();
	ncn_setup();
	cm_enable_interrupts();

	while (1) {
		__WFI();
	}

	return 0;
}
Пример #7
0
/*
 * main() - Application main entry
 *
 * INPUT
 *     none
 * OUTPUT
 *     0 when complete
 */
int main(void)
{
    /* Init for safeguard against stack overflow (-fstack-protector-all) */
    __stack_chk_guard = (uintptr_t)random32();

    /* Init board */
    board_init();
    led_func(SET_RED_LED);
    dbg_print("Application Version %d.%d.%d\n\r", MAJOR_VERSION, MINOR_VERSION,
              PATCH_VERSION);

    /* Init storage */
    storage_init();

    /* Init protcol buffer message map and usb msg callback */
    fsm_init();

    led_func(SET_GREEN_LED);
    
    screen_test();

    /* Enable interrupt for timer */
    cm_enable_interrupts();

    usb_init();
    led_func(CLR_RED_LED);

    reset_idle_time();

    while(1)
    {
        delay_ms_with_callback(ONE_SEC, &exec, 1);
        increment_idle_time(ONE_SEC);
        toggle_screensaver();
    }

    return(0);
}
Пример #8
0
void enable_interrupts() {
  cm_enable_interrupts();
}
Пример #9
0
void sys_tick_handler(void) {
  cm_disable_interrupts();
  check_rollover();
  cm_enable_interrupts();
}
Пример #10
0
void cpu_enable_int( void )
{
	cm_enable_interrupts();
}