void nqueens_by_level(std::vector<unsigned int> pos, unsigned int start_level, unsigned int max_level, void (* const success_func)(std::vector<unsigned int>&)) { if(start_level==max_level){ success_func(pos); return; } for(uint col=0; col<pos.capacity(); col++){ if(isValid(col, start_level, pos)){ pos[start_level]=col; nqueens_by_level(pos, start_level+1, max_level, success_func); } } }
void i2cman_handler() { ROM_I2CMasterIntClear(I2C_PORT); if(current_op == end || current_op == 0) return; // do absolutely nothing (irq may be called after aborting) uint32_t error = finish_op(current_op); if(error != I2C_MASTER_ERR_NONE) { stop(); if(error & I2C_MASTER_ERR_ARB_LOST) { if(error_func) error_func(I2C_ARBLOST); } else { // error, abort completely //kill_op(current_op); // bad bad bad! if(error_func) error_func(I2C_NOACK); } return; } current_op ++; if(current_op == end) { stop(); // all done if(success_func) success_func(); return; } // otherwise, process the next op start_op(current_op); }