fix systick, i2c interrupt handlers not defined as interrupt
This commit is contained in:
		
							parent
							
								
									8d82d83568
								
							
						
					
					
						commit
						56cd06876a
					
				@ -31,6 +31,7 @@ void HardFault_Handler(void)
 | 
			
		||||
    while (1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__attribute__((interrupt("WCH-Interrupt-fast")))
 | 
			
		||||
void SysTick_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
    // ---- PROCESS UI AND COMMS
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,8 @@
 | 
			
		||||
 * some notes:
 | 
			
		||||
 * - writing does not loop; if writing to the end then new writes will cause an error interrupt.
 | 
			
		||||
 * - added write protection for first 16 bytes.
 | 
			
		||||
 * - many registers will only commit to action upon valid I2C stop received.
 | 
			
		||||
 * - the code don't send NACKs on invalid writes.
 | 
			
		||||
 * - write registers will only commit to action upon valid I2C stop received.
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * register map:
 | 
			
		||||
@ -129,8 +130,8 @@ void i2cs_write_cb(uint16_t initial_reg, uint16_t last_reg)
 | 
			
		||||
// error - see i2c_slave.h for error types
 | 
			
		||||
void i2cs_werr_cb(uint16_t reg, uint8_t data, uint8_t error)
 | 
			
		||||
{
 | 
			
		||||
    i2cs_reg[0x0d]++;
 | 
			
		||||
    if (!i2cs_reg[0x0d]) i2cs_reg[0x0c]++;
 | 
			
		||||
    i2cs_reg[REG_WERR_LO]++;
 | 
			
		||||
    if (!i2cs_reg[REG_WERR_LO]) i2cs_reg[REG_WERR_HI]++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// called upon every register read
 | 
			
		||||
@ -208,7 +209,7 @@ void I2C1_EV_IRQHandler(void)
 | 
			
		||||
        i2cs_state.position = i2cs_state.offset; // Reset position
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (STAR1 & I2C_STAR1_RXNE) { // Write event
 | 
			
		||||
    if (STAR1 & I2C_STAR1_RXNE) { // Write from master event
 | 
			
		||||
        if (i2cs_state.first_write == 2) { // low address byte written; set the offset
 | 
			
		||||
            i2cs_state.offset = i2cs_state.offset | I2C1->DATAR;
 | 
			
		||||
            i2cs_state.position = i2cs_state.offset;
 | 
			
		||||
@ -240,7 +241,7 @@ void I2C1_EV_IRQHandler(void)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (STAR1 & I2C_STAR1_TXE) { // Read event
 | 
			
		||||
    if (STAR1 & I2C_STAR1_TXE) { // Read to master event
 | 
			
		||||
        i2cs_state.writing = 0;
 | 
			
		||||
        if (i2cs_state.position < i2cs_state.reg_len) {
 | 
			
		||||
            I2C1->DATAR = i2cs_state.reg_file[i2cs_state.position];
 | 
			
		||||
@ -262,6 +263,7 @@ void I2C1_EV_IRQHandler(void)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__attribute__((interrupt("WCH-Interrupt-fast")))
 | 
			
		||||
void I2C1_ER_IRQHandler(void)
 | 
			
		||||
{
 | 
			
		||||
    uint16_t STAR1 = I2C1->STAR1;
 | 
			
		||||
 | 
			
		||||
@ -140,6 +140,7 @@ int main(void)
 | 
			
		||||
    exti_nvic_init();
 | 
			
		||||
 | 
			
		||||
    // configure systick
 | 
			
		||||
    systick_init();
 | 
			
		||||
 | 
			
		||||
    while (1) {
 | 
			
		||||
        __WFI();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user