Skip to content
Snippets Groups Projects
Select Git revision
  • 51f9da1bab4c84a776dcccd41e48aa5e1e99f9de
  • main default protected
  • phhw
  • captouch-threshold
  • t
  • dos
  • test2
  • test
  • slewtest
  • simtest
  • view-think
  • vm-pending
  • media-buf
  • scope
  • passthrough
  • wave
  • vsync
  • dos-main-patch-50543
  • json-error
  • rahix/big-flow3r
  • pippin/media_framework
  • v1.3.0
  • v1.2.0
  • v1.2.0+rc1
  • v1.1.1
  • v1.1.0
  • v1.1.0+rc1
  • v1.0.0
  • v1.0.0+rc6
  • v1.0.0+rc5
  • v1.0.0+rc4
  • v1.0.0+rc3
  • v1.0.0+rc2
  • v1.0.0+rc1
34 results

led_strip_rmt_ws2812.c

Blame
  • Forked from flow3r / flow3r firmware
    Source project has a limited visibility.
    mphalport.c 2.18 KiB
    #include <stdint.h>
    
    #include "py/lexer.h"
    #include "py/mpconfig.h"
    #include "py/mperrno.h"
    #include "py/mpstate.h"
    #include "py/obj.h"
    #include "py/runtime.h"
    
    #include "mxc_delay.h"
    #include "max32665.h"
    #include "tmr.h"
    
    #include "epicardium.h"
    
    /******************************************************************************
     * Serial Communication
     */
    
    /* Receive single character */
    int mp_hal_stdin_rx_chr(void)
    {
    	return (int)epic_uart_read_chr();
    }
    
    /* Send string of given length */
    void mp_hal_stdout_tx_strn(const char* str, mp_uint_t len)
    {
    	epic_uart_write_str(str, len);
    }
    
    bool do_interrupt = false;
    
    /* Timer Interrupt used for control char notification */
    void TMR5_IRQHandler(void)
    {
    	TMR_IntClear(MXC_TMR5);
    
    	if (do_interrupt) {
    		/* Taken from lib/micropython/micropython/lib/utils/interrupt_char.c */
    		MP_STATE_VM(mp_pending_exception) =
    			MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
    #if MICROPY_ENABLE_SCHEDULER
    		if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
    			MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
    		}
    #endif
    	}
    }
    
    void mp_hal_set_interrupt_char(char c)
    {
    	if (c != -1) {
    		mp_obj_exception_clear_traceback(
    			MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))
    		);
    	}
    	do_interrupt = (c == 0x03);
    }
    
    /******************************************************************************
     * Time & Delay
     */
    
    void mp_hal_delay_ms(mp_uint_t ms)
    {
    	mxc_delay(ms * 1000);
    }
    
    void mp_hal_delay_us(mp_uint_t us)
    {
    	mxc_delay(us);
    }
    
    /******************************************************************************
     * Fatal Errors
     */
    
    extern NORETURN void * Reset_Handler (void);
    
    void NORETURN nlr_jump_fail(void* val)
    {
    	char msg[] = " >>> nlr_jump_fail <<<\r\n";
    	epic_uart_write_str(msg, sizeof(msg));
    
    	Reset_Handler();
    }
    
    /******************************************************************************
     * Stubs
     */
    
    mp_lexer_t* mp_lexer_new_from_file(const char* filename)
    {
    	/* TODO: Do we need an implementation for this? */
    	mp_raise_OSError(MP_ENOENT);
    }
    
    mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t* args, mp_map_t* kwargs)
    {
    	/* TODO: Once fs is implemented, get this working as well */
    	return mp_const_none;
    }
    MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);