Jump to content

yaoyutaoTom

Members
  • Posts

    9
  • Joined

  • Last visited

Posts posted by yaoyutaoTom

  1. Now, I have completed a key driver,

    #define GINPUT_TOGGLE_NUM_PORTS			3			// The total number of toggle inputs
    #define GINPUT_TOGGLE_CONFIG_ENTRIES	1
    
    #define GINPUT_TOGGLE_DECLARE_STRUCTURE()											\
    const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = {	\
    		{GPIOC,								\
    			GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9,											\
    			GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9,											\
    			GPIO_Mode_IN}													\
    	}
    
    	
    GINPUT_TOGGLE_DECLARE_STRUCTURE();
    
    void ginput_lld_toggle_init(const GToggleConfig *ptc) 
    {
    	key_init();
    }
    
    unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc) {
    	return GPIO_ReadInputData(GPIOC);
    }

    if the key GPIOC.7 is pressed, how do I check the key event in a win ?

  2. I want to implement a key driver. And I see the example in the gdrivers.

    GINPUT_TOGGLE_DECLARE_STRUCTURE();
    
    void ginput_lld_toggle_init(const GToggleConfig *ptc) {
    	palSetGroupMode(((IOBus *)ptc->id)->portid, ptc->mask, 0, ptc->mode);
    }
    
    unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc) {
    	return palReadBus((IOBus *)ptc->id);
    }
    // Describes how the toggle bits are obtained
    typedef struct GToggleConfig_t {
    	void		*id;
    	unsigned	mask;
    	unsigned	invert;
    	unsigned	mode;
    } GToggleConfig;

    But I have no idea how to write the code, is there a example ? what's the mean of invert ?

    I use in bare metal mode.  no palSetGroupMode() function, no IOBus * type

  3. I  run the demo arcsectors. But the gfxSleepMilliseconds()  stuck.

    here is my code

    int main(void)
    {        
        coord_t        width, height, r1, r2, cx, cy;
        uint8_t        sectors;
        
        SysTick_Config(SystemCoreClock / 1000);    
        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);    
        lcd_init();    
        win_flash();    
        delay(1000);
        lcd_clear();
        
        gfxInit();
        
        // Get the screen size
        width = gdispGetWidth();
        height = gdispGetHeight();
    
        // Initialize some variables
        r1 = width > height ? height/3 : width/3;
        r2 = r1*3/4;
        cx = width/2;
        cy = height/2;
        sectors = 1;
        
        while(1) {
            // Draw the arc sectors
            gdispClear(White);
            gdispDrawArcSectors(cx, cy, r1, sectors, Black);
            gdispFillArcSectors(cx, cy, r2, sectors, Black);
    
            // Increase the sectors counter
            sectors++;
    
            // Waste some time
            gfxSleepMilliseconds(250);
        }
    }
    
    
    
    
    static volatile uint32_t gfx_tick = 0;
    static volatile uint32_t cnt = 0;
    
    systemticks_t gfxSystemTicks(void)
    {
        return gfx_tick;
    }
     
    systemticks_t gfxMillisecondsToTicks(delaytime_t ms)
    {
        return ms;
    }
    
    
    void SysTick_Handler(void)
    {    
    
        gfx_tick ++;
        
        if (0 != cnt)
            cnt--;
    }
    
    extern void delay(uint16_t val)
    {
        cnt = val;
        while(cnt);
    }

    if I replace the gfxSleepMilliseconds(250) with delay(250), it is OK. what is wrong with it ?

×
×
  • Create New...