本文整理汇总了C++中sei函数的典型用法代码示例。如果您正苦于以下问题:C++ sei函数的具体用法?C++ sei怎么用?C++ sei使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sei函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: fetch_op
//.........这里部分代码省略.........
/* EOR nnnn,X */
case 0x5D: eor(load_byte(addr_absx()),4); break;
/* LSR nnnn,X */
case 0x5E: lsr_mem(addr_absx(),7); break;
/* RTS */
case 0x60: rts(); break;
/* ADC (nn,X) */
case 0x61: adc(load_byte(addr_indx()),6); break;
/* ADC nn */
case 0x65: adc(load_byte(addr_zero()),3); break;
/* ROR nn */
case 0x66: ror_mem(addr_zero(),5); break;
/* PLA */
case 0x68: pla(); break;
/* ADC #nn */
case 0x69: adc(fetch_op(),2); break;
/* ROR A */
case 0x6A: ror_a(); break;
/* JMP (nnnn) */
case 0x6C: jmp_ind(); break;
/* ADC nnnn */
case 0x6D: adc(load_byte(addr_abs()),4); break;
/* ROR nnnn */
case 0x6E: ror_mem(addr_abs(),6); break;
/* BVS */
case 0x70: bvs(); break;
/* ADC (nn,Y) */
case 0x71: adc(load_byte(addr_indy()),5); break;
/* ADC nn,X */
case 0x75: adc(load_byte(addr_zerox()),4); break;
/* ROR nn,X */
case 0x76: ror_mem(addr_zerox(),6); break;
/* SEI */
case 0x78: sei(); break;
/* ADC nnnn,Y */
case 0x79: adc(load_byte(addr_absy()),4); break;
/* ADC nnnn,X */
case 0x7D: adc(load_byte(addr_absx()),4); break;
/* ROR nnnn,X */
case 0x7E: ror_mem(addr_absx(),7); break;
/* STA (nn,X) */
case 0x81: sta(addr_indx(),6); break;
/* STY nn */
case 0x84: sty(addr_zero(),3); break;
/* STA nn */
case 0x85: sta(addr_zero(),3); break;
/* STX nn */
case 0x86: stx(addr_zero(),3); break;
/* DEY */
case 0x88: dey(); break;
/* TXA */
case 0x8A: txa(); break;
/* STY nnnn */
case 0x8C: sty(addr_abs(),4); break;
/* STA nnnn */
case 0x8D: sta(addr_abs(),4); break;
/* STX nnnn */
case 0x8E: stx(addr_abs(),4); break;
/* BCC nn */
case 0x90: bcc(); break;
/* STA (nn,Y) */
case 0x91: sta(addr_indy(),6); break;
/* STY nn,X */
case 0x94: sty(addr_zerox(),4); break;
/* STA nn,X */
case 0x95: sta(addr_zerox(),4); break;
开发者ID:CameronBanga,项目名称:emudore,代码行数:67,代码来源:cpu.cpp
示例2: main
int main(void)
{
char remotePrev = 0;
signed char remoteValue;
unsigned int cowDelay = 0;
unsigned char cowDirection = FORWARD;
unsigned char count = 0;
unsigned int motorb_current = 0;
char motorb_safety = ON;
char name[15];
timer0_prescale(TMR0_PRE1024);
// set_bit(TIMSK0, TOIE0);
twiMasterInit(100000);
sei();
hcmmod_rc(DISABLE);
iomod_text(FIRST_LINE, "Darla Rules");
//darla_relay(0x00);
// while (1);
while (TRUE) {
if (masterCounter > cowDelay) {
clear_bit(TIMSK0, TOIE0);
masterCounter = 0;
if (cowDirection == FORWARD)
hcmd_drive_limit(MOTORB, +40, 1);
else if (cowDirection == REVERSE)
hcmd_drive_limit(MOTORB, -40, 2);
}
remoteValue = iomod_remote();
if (remoteValue != -1)
iomod_decimal(FIRST_LINE, remoteValue, 4);
//if (remoteValue == 1) {
if ((remoteValue == 1) && (remotePrev != 1)) {
masterCounter = 0;
cowDirection = FORWARD;
cowDelay = 2400;
set_bit(TIMSK0, TOIE0);
darla_send_set(darlaSet1, 7);
mp3mod_play_file("o1NEWMC.mp3");
/* Need to avoid multiple calls from remote, which seemed to be the
* cause of problems with the MP3 not working. */
//delay_ms(1000);
remotePrev = 1;
}
//else if (remoteValue == 2) {
else if ((remoteValue == 2) && (remotePrev != 2)) {
masterCounter = 0;
cowDirection = REVERSE;
cowDelay = 50;
set_bit(TIMSK0, TOIE0);
darla_send_set(darlaSet2, 3);
mp3mod_play_file("i2MTC.mp3");
remotePrev = 2;
//delay_ms(1000);
}
else if (remoteValue == 4)
hcmd_drive_limit(MOTORB, +40, 1);
else if (remoteValue == 6)
hcmd_drive_limit(MOTORB, -40, 2);
else if (remoteValue == 5)
hcmd_stop_motor(MOTORB, BRAKE);
else if (remoteValue == 7)
darla_relay(OFF);
else if (remoteValue == 8)
darla_relay(MM);
else if (remoteValue == 9)
darla_relay(UC);
// darla_send_set(darlaSetT, 2);
/* Prevent Darla from moving if current draw is too high */
iomod_decimal(SECOND_LINE, hcmmod_current(MOTORB), 6);
motorb_current = hcmmod_current(MOTORB);
if ((motorb_current > 200) && (motorb_safety == ON))
hcmd_stop_motor(MOTORB, BRAKE);
}
}
开发者ID:medfordengineering,项目名称:oldcode,代码行数:80,代码来源:darla_master.c
示例3: INT0_vect
void INT0_vect ( void )
{
cli ();
printf ("I am in an interrupt----------->\n");
sei ();
}
开发者ID:arunkumarv31,项目名称:rtos,代码行数:6,代码来源:main.c
示例4: main
int main( void )
{
// Enable interrupts as early as possible
sei();
Timer_Init();
// Set as outputs and stop rotor
DDRD |= (1 << PD1)|(1 << PD2);
PORTD &= ~((1 << PD1)|(1 << PD2));
// Setup ADC
initAdcFeedback();
Can_Message_t txMsg;
txMsg.Id = (CAN_NMT_APP_START << CAN_SHIFT_NMT_TYPE) | (NODE_ID << CAN_SHIFT_NMT_SID);
txMsg.DataLength = 4;
txMsg.RemoteFlag = 0;
txMsg.ExtendedFlag = 1;
txMsg.Data.words[0] = APP_TYPE;
txMsg.Data.words[1] = APP_VERSION;
// Set up callback for CAN reception
BIOS_CanCallback = &can_receive;
// Send CAN_NMT_APP_START
BIOS_CanSend(&txMsg);
// Read calibration value from eeprom
azimuthCalibration = eeprom_read_word( CALIBRATE_AZIMUTH );
// Timer for reading position feedback
Timer_SetTimeout(0, 100, TimerTypeFreeRunning, 0);
Timer_SetTimeout(1, 1000, TimerTypeFreeRunning, 0);
sendStatus( STATUS );
while (1) {
if (Timer_Expired(0)) {
// Periodicly read antennas position
readFeedback();
}
if (Timer_Expired(1)) {
sendStatus(STATUS);
}
if (rxMsgFull) {
switch (rxMsg.Id){
case MSG_CAL_SET: // Set calibration value
if( 2 == rxMsg.DataLength ){
calibration( SET, rxMsg.Data.words[0] );
}
break;
case MSG_CAL_GET: // Get calibration value
if( 0 == rxMsg.DataLength ){
txMsg.Id = MSG_CAL_RET;
txMsg.DataLength = 2;
txMsg.Data.words[0] = calibration( GET, 0 );
BIOS_CanSend(&txMsg);
}
break;
case MSG_ABS: // Start turning to absolute position
if( 2 == rxMsg.DataLength ){
}
break;
case MSG_REL: // Start turning to relative position
if( 2 == rxMsg.DataLength ){
}
break;
case MSG_START: // Start turning
if( 1 == rxMsg.DataLength ){
// First data byte decides direction
controlRelay( rxMsg.Data.bytes[0] );
}
break;
case MSG_STOP: // Stop turning
//if( 1 == rxMsg.DataLength ){
controlRelay( ROTATE_STOP );
//}
break;
case MSG_STATUS: // Get position
if( 0 == rxMsg.DataLength ){
sendStatus(STATUS);
}
break;
default:
break;
}
rxMsgFull = 0; //
}
}
//.........这里部分代码省略.........
开发者ID:Cougar,项目名称:HomeAutomation,代码行数:101,代码来源:main.c
示例5: main
int main(void)
{
SetSystemClockPrescaler(0);
init();
sei();
led_blink(3);
while (1)
{
if(SW_ACTIVE())
{
// SW pressed
uint8_t pressCnt = 100;
// wait until released
do
{
// long term press detected?
if(pressCnt>0 && --pressCnt==0)
LED_ON();
_delay_ms(10);
} while(SW_ACTIVE());
// SW released
LED_OFF();
if(pressCnt>0)
handleSensor(1); // force transmit
else
{
// program mode
LED_ON();
fs20_resetbuffer();
fs20_rxon();
fstelegram_t t;
t.type = 'U'; // undefined
pressCnt = 100;
// wait for next telegram
// exit if button pressed or timeout occured
while(!fs20_readFS20Telegram(&t) && --pressCnt>0 && !SW_ACTIVE())
_delay_ms(100);
fs20_idle();
LED_OFF();
// save the result
if(t.type=='F')
{
saveConfig(t.housecode, t.button);
led_blink(2); // confirm save of config
handleSensor(1); // force transmit
}
// wait until sw releases
while(SW_ACTIVE());
}
}
// check long term timer
if(longTimerCnt >= LONGTIMER_VAL)
handleSensor(1);
// finaly check if sensor value changed
// this will only be the case if the current sensor value haven't been sent
// during this cycle
handleSensor(0);
// sleep well
LED_OFF();
SENS_ACTIVATE(0);
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_mode();
}
}
开发者ID:Diggen85,项目名称:a-culfw,代码行数:77,代码来源:main.c
示例6: set_time
void set_time(bool timeType){
int *hou = &hour;
int *min = &minute;
update_timeXPos(hour, minute);
if (timeType == ALARM_TYPE){
hou = &alarm_hour;
min = &alarm_minute;
update_timeXPos(alarm_hour, alarm_minute);
}
int item = 0;
int old_selectedItem = 1;
cli();
btn_drehenc_pushed = false;
sei();
clear_pixelMatrix();
print_time(timeType);
print_symbol(16,17, hakenSymb,108,46);
print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,timeXPos+get_timeWidth(alarm_hour)/2-4, 2);
update_LCD();
while(item != 2){
while(!btn_drehenc_pushed){
if(rotary != 0){
item += rotary;
cli();
rotary = 0;
sei();
item = item % 3;
if(item<0){
item += 3;
}
switch (old_selectedItem){
case 0: for(int x = 0; x<128; x++){
for(int y = 2; y<10; y++)
reset_pixel(x,y);
} break;
case 1: for(int x = 0; x<128; x++){
for(int y = 2; y<10; y++)
reset_pixel(x,y);
}break;
case 2: for(int x = 92; x<102; x++){
for(int y = 2+3*15+5; y<2+3*15+8+5; y++)
reset_pixel(x,y);
}break;
}
switch (item) {
case 0: print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,timeXPos+hourWidth/2-4, 2); break;
case 1: print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,timeXPos+hourWidth+2*SPACE_TO_DOTS+ TIMEDOT_WIDTH + minuteWidth/2-4, 2); break;
case 2: print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb, 92, 2+3*15+5);break;
}
old_selectedItem = item;
update_LCD();
}
goodNight();
check_light();
}
cli();
btn_drehenc_pushed = false;
sei();
switch (item) {
case 0: {
print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinOffenSymb,timeXPos+hourWidth/2-4, 2);
update_LCD();
set_timeParameter(hou, 24, timeType);
print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,timeXPos+hourWidth/2-4, 2);
break;
}
case 1: {
print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinOffenSymb,timeXPos+hourWidth+2*SPACE_TO_DOTS+ TIMEDOT_WIDTH + minuteWidth/2-4, 2);
update_LCD();
set_timeParameter(min, 60, timeType);
print_symbol(8,HERZ_KLEIN_WIDTH,herzKleinSymb,timeXPos+hourWidth+2*SPACE_TO_DOTS+ TIMEDOT_WIDTH + minuteWidth/2-4, 2);
break;
}
case 2: { seconds = 0;
cli();
TCNT2 = 0;
timeAdvance = 0;
timeUpdate = 0;
sei();
break;
}
}
update_LCD();
}
}
开发者ID:MalteBastelt,项目名称:Wecker,代码行数:88,代码来源:EADOGL128.c
示例7: door_main
int
door_main(void)
{
serial_init(9600, 8e2);
pin13_mode_output();
pin_mode_input(PIN_CLK); /* clk */
pin_mode_input(PIN_DATA); /* data */
pin_mode_output(PIN_GREEN_LED); /* green led lock */
pin_mode_output(PIN_YELLOW_LED); /* yellow led lock */
pin_mode_output(PIN_OPEN_LOCK); /* open */
pin_mode_output(PIN_DAYMODE); /* stay open */
pin_mode_output(PIN_STATUS_LED); /* yellow status */
pin_high(PIN_OPEN_LOCK);
pin_high(PIN_DAYMODE);
pin_high(PIN_GREEN_LED);
pin_high(PIN_YELLOW_LED);
/* trigger pin2 interrupt when the clock
* signal goes high */
pin2_interrupt_mode_rising();
pin2_interrupt_enable();
data_reset();
/* setup timer1 to trigger interrupt a 4 times a second */
timer1_mode_ctc();
timer1_compare_a_set(62499);
timer1_clock_d64();
timer1_interrupt_a_enable();
softserial_init();
pin_mode_output(PIN_RFID_ENABLE);
pin_low(PIN_RFID_ENABLE);
sleep_mode_idle();
while (1) {
/*
* sleep if no new events need to be handled
* while avoiding race conditions. see
* http://www.nongnu.org/avr-libc/user-manual/group__avr__sleep.html
*/
cli();
if (events == EV_NONE && !ev_softserial) {
sleep_enable();
sei();
sleep_cpu();
sleep_disable();
continue;
}
sei();
if (events & EV_SERIAL) {
handle_serial_input();
continue;
}
if (ev_softserial) {
handle_rfid_input();
}
events &= ~EV_DATA;
if (cnt > 0 && data[cnt - 1] == 0xB4) {
if (cnt >= 10) {
struct sha1_context ctx;
char digest[SHA1_DIGEST_LENGTH];
sha1_init(&ctx);
sha1_update(&ctx, (char *)data, 256);
sha1_final(&ctx, digest);
serial_print("HASH+");
serial_hexdump(digest, SHA1_DIGEST_LENGTH);
serial_print("\n");
}
data_reset();
continue;
}
events &= ~EV_TIME;
if (second > 10*4) {
serial_print("ALIVE\n");
second = 0;
data_reset();
continue;
}
}
}
开发者ID:knielsen,项目名称:doorduino,代码行数:90,代码来源:doorduino.c
示例8: main
//.........这里部分代码省略.........
mcp9800_addr = 0x48;
}
else
{
mcp9800_addr = 0x4D;
}
/*-----------------------------------------------------------------------*/
/* Set MCP9800 to 12 bit resolution */
/*-----------------------------------------------------------------------*/
I2C_Start();
I2C_Write(write_address(mcp9800_addr));
I2C_Write(0x01);
I2C_Write((1<<7)|(1<<6)|(1<<5));
I2C_Stop();
/*-----------------------------------------------------------------------*/
/* Set MCP9800 Register Pointer to Ambient Temperature */
/*-----------------------------------------------------------------------*/
I2C_Start();
I2C_Write(write_address(mcp9800_addr));
I2C_Write(0x00);
I2C_Stop();
while(1)
{
/*-------------------------------------------------------------------*/
/* MCP9800: Cold junction channel */
/*-------------------------------------------------------------------*/
usbPoll();
I2C_Start();
debug[0] = I2C_Write(read_address(mcp9800_addr));
tmpReadout[0] = I2C_Read(ACK);
tmpReadout[1] = I2C_Read(NO_ACK);
I2C_Stop();
movAvg_read = ((int16_t)tmpReadout[0] << 8) + ((int16_t)tmpReadout[1]);
movAvg_sum -= movAvg_mem[movAvg_ind];
movAvg_sum += movAvg_read;
movAvg_mem[movAvg_ind] = movAvg_read;
if(movAvg_ind == 7)
{
movAvg_ind = 0;
movAvg_stabil = 1;
}
else
{
movAvg_ind++;
}
if(movAvg_stabil == 1)
{
movAvg_read = movAvg_sum >> 3;
}
usbPoll();
cli();
coldJunctionReadout[0] = movAvg_read >> 8;
coldJunctionReadout[1] = movAvg_read & 0xFF;
sei();
/*-------------------------------------------------------------------*/
/* MCP3421: 3.75 SPS + 18 Bits + Initiate new conversion
/*-------------------------------------------------------------------*/
usbPoll();
I2C_Start();
I2C_Write(write_address(mcp3421_addr));
I2C_Write((1<<7)|(1<<3)|(1<<2)|gainSetting);
I2C_Stop();
/*-------------------------------------------------------------------*/
/* Small delay ...
/*-------------------------------------------------------------------*/
timer0_counter = 250;
while(timer0_counter)
{
usbPoll();
}
/*-------------------------------------------------------------------*/
/* MCP3421
/*-------------------------------------------------------------------*/
usbPoll();
I2C_Start();
I2C_Write(read_address(mcp3421_addr));
tmpReadout[0] = I2C_Read(ACK);
tmpReadout[1] = I2C_Read(ACK);
tmpReadout[2] = I2C_Read(ACK);
tmpReadout[3] = I2C_Read(NO_ACK);
I2C_Stop();
usbPoll();
cli();
thermocoupleReadout[0] = tmpReadout[0];
thermocoupleReadout[1] = tmpReadout[1];
thermocoupleReadout[2] = tmpReadout[2];
thermocoupleReadout[3] = tmpReadout[3];
sei();
}
开发者ID:PaxInstruments,项目名称:t100-firmware,代码行数:101,代码来源:main.c
示例9: main
int main(void)
{
{ // Set up timers, sleep and such
cli();
set_sleep_mode(SLEEP_MODE_IDLE);
PRR = ((1 << PRTIM1) | (1 << PRUSI) | (1 << PRADC));
// TIMER0
TCCR0A = (1 << WGM01);
TCCR0B = ((1 << CS01) | (1 << CS00));
OCR0A = 61;
OCR0B = 0;
TIMSK = (1 << OCIE0A);
// INT0
MCUCR |= (1 << ISC01);
GIMSK = (1 << INT0);
PORTB = PORTB_NULL;
counter = leds = 0;
counter_max = MAXIMUM;
piezo = 0;
stopped = 1;
sei();
}
{ // Set up the counter and start
while (stopped < 3)
{
leds = counter_max;
sleep_mode();
}
leds = LED_ON;
}
{ // Prepare for the timer
cli();
GIMSK = 0; // Stop INT0
stopped = 0;
TCNT0 = 0; // Clear TIMER0
sei();
}
{ // Display the timer while it's running
while (counter < counter_max)
{
leds = counter | LED_ON;
sleep_mode();
}
stopped = 4;
leds = counter;
}
{ // Yell!
cli();
GIMSK = (1 << INT0); // Start INT0
sei();
while (stopped == 4) // Sleep!
sleep_mode();
GIMSK = 0; // Stop INT0
TCCR0A &= ~((1 << COM0B1) | (1 << COM0B0)); // Stop yelling!
}
{ // Timer finished, sleep forever!
cli();
TIMSK = 0;
PORTB = 0; // Everything off
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_mode();
}
return 0;
}
开发者ID:Tomin1,项目名称:ajastin,代码行数:64,代码来源:ajastin.c
示例10: main
/**
* Entry point
*/
int main(void) {
/* Misc variables */
DCPU_registers reg; // CPU registers states (at boot)
/* Hardware initialisation */
cli();
led_setup();
spi_setup(SPI_PRESCALER, SPI_MODE, SPI_BITS_ORDER);
uart_setup(UART_BAUDRATE);
DEBUG_STR("Main init", "UART ready");
button_setup();
buzzer_setup(BUZZER_FREQUENCY, BUZZER_DURATION);
ram_setup();
rom_setup();
microvga_setup();
microvga_enable();
dcpu_register_init(®);
DEBUG_STR("Main init", "done");
sei();
/* MicroVGA initialisation */
_delay_ms(1000); // MicroVGA boot time
microvga_clear_screen(); // Clear screen and goto (0, 0)
microvga_goto_cursor(0, 0);
uart_puts_PSTR(PSTR("SkyWodd DCPU-16 hardware emulator")); // Screen test
buzzer_beep();
DEBUG_STR("Main init", "MicroVGA ready");
/* Hardware self-test */
DEBUG_STR("Main init", "self-test run");
led_run_write(1); // Led test
_delay_ms(250);
led_run_write(0);
led_cpu_write(1);
_delay_ms(250);
led_cpu_write(0);
led_rom_write(1);
_delay_ms(250);
led_rom_write(0);
led_ram_write(1);
_delay_ms(250);
led_ram_write(0);
DEBUG_STR("Main init", "self-test done");
/* Keyboard & MicroVGA api test */
DEBUG_STR("Main init", "waiting for keypress");
microvga_goto_cursor(0, 1);
uart_puts_PSTR(PSTR("Press any key to boot ..."));
keyboard_wait();
uart_puts_PSTR(PSTR("Loading please wait ..."));
dcpu_setup(reg);
buzzer_beep();
microvga_clear_screen();
microvga_goto_cursor(0, 0);
DEBUG_STR("Main init", "ready to run");
/* Infinite loop */
for(;;) {
/* Handle pause */
while(!button_get_state());
#ifdef SERIAL_DEBUG_SUPPORT
/* Debug */
dcpu_registers_dump();
#endif
/* Fetch opcode from ROM */
dcpu_step();
}
}
开发者ID:skywodd,项目名称:AVR_DCPU_16,代码行数:76,代码来源:main.c
示例11: bluetooth_parse_command
static void bluetooth_parse_command(uint8_t len)
{
uint8_t response = RESPONSE_OK;
sei();
if (len == 0) {
response = RESPONSE_NO_RESPONSE;
} else if (strncmp(rxbuff, BLUETOOTH_CMD_HELP, len) == 0) {
uint8_t i = 0;
for (i = 1; i < sizeof(commands) / sizeof(commands[0]); i ++) {
uart_puts(commands[i]);
if ((i % 3) == 0) {
uart_puts("\r\n");
} else {
uint8_t padding = 0, j = 0;
padding = 26 - strlen(commands[i]);
for (j = 0; j < padding; j++) {
uart_putc(' ');
}
}
}
if (((i - 1) % 3) != 0) {
uart_puts("\r\n");
}
response = RESPONSE_NO_RESPONSE;
} else if (strncmp(rxbuff, BLUETOOTH_CMD_BATTERY, len) == 0) {
uint8_t capacity = 0;
char resp[16];
capacity = battery_get_capacity();
itoa(capacity, resp, 10);
uart_puts(BLUETOOTH_CMD_BATTERY);
uart_puts(": ");
uart_puts(resp);
uart_puts("%\r\n");
response = RESPONSE_NO_RESPONSE;
} else if (strncmp(rxbuff, BLUETOOTH_CMD_ECHO, len) == 0) {
echo = TRUE;
uart_puts("\r\n");
response = RESPONSE_NO_RESPONSE;
} else if (strncmp(rxbuff, BLUETOOTH_CMD_EYES, strlen(BLUETOOTH_CMD_EYES)) == 0) {
char *param = rxbuff + strlen(BLUETOOTH_CMD_EYES) + 1;
if (len == strlen(BLUETOOTH_CMD_EYES) + strlen(BLUETOOTH_PARAM_ON) + 1) {
if (strncmp(param, BLUETOOTH_PARAM_ON, strlen(BLUETOOTH_PARAM_ON)) == 0) {
power_on(EYES);
} else {
response = RESPONSE_ERROR;
}
} else if (len == strlen(BLUETOOTH_CMD_EYES) + strlen(BLUETOOTH_PARAM_OFF) + 1) {
if (strncmp(param, BLUETOOTH_PARAM_OFF, strlen(BLUETOOTH_PARAM_OFF)) == 0) {
power_off(EYES);
} else {
response = RESPONSE_ERROR;
}
} else if (len == strlen(BLUETOOTH_CMD_EYES)) {
uint8_t state = power_state(EYES);
uart_puts(BLUETOOTH_CMD_EYES);
uart_puts(": ");
if (state == POWER_ON) {
uart_puts(BLUETOOTH_PARAM_ON);
} else {
uart_puts(BLUETOOTH_PARAM_OFF);
}
uart_puts("\r\n");
response = RESPONSE_NO_RESPONSE;
} else {
response = RESPONSE_ERROR;
}
} else if (strncmp(rxbuff, BLUETOOTH_CMD_HELMET, strlen(BLUETOOTH_CMD_HELMET)) == 0) {
char *param = rxbuff + strlen(BLUETOOTH_CMD_HELMET) + 1;
if (len == strlen(BLUETOOTH_CMD_HELMET) + strlen(BLUETOOTH_PARAM_OPEN) + 1) {
if (strncmp(param, BLUETOOTH_PARAM_OPEN, strlen(BLUETOOTH_PARAM_OPEN)) == 0) {
helmet_open();
} else {
response = RESPONSE_ERROR;
}
} else if (len == strlen(BLUETOOTH_CMD_HELMET) + strlen(BLUETOOTH_PARAM_CLOSE) + 1) {
if (strncmp(param, BLUETOOTH_PARAM_CLOSE, strlen(BLUETOOTH_PARAM_CLOSE)) == 0) {
helmet_close();
} else {
response = RESPONSE_ERROR;
}
} else if (len == strlen(BLUETOOTH_CMD_HELMET)) {
uint8_t state = helmet_state();
uart_puts(BLUETOOTH_CMD_HELMET);
uart_puts(": ");
//.........这里部分代码省略.........
开发者ID:JLeo-Omsk,项目名称:jarvis-2.0,代码行数:101,代码来源:bluetooth.c
示例12: main
/*
* //~ uart_puts_P("G21\n");
//~ get_grbl_response();
//~ uart_puts_P("G90\n");
//~ get_grbl_response();
//~ uart_puts_P("G94\n");
//~ get_grbl_response();
//~ uart_puts_P("G17\n");
//~ get_grbl_response();
//~ uart_puts_P("M3 S1000\n");
//~ get_grbl_response();
//~ uart_puts_P("F800.00\n");
//~ get_grbl_response();
//~ uart_puts_P("G0 Z1.00\n");
//~ get_grbl_response();
//~ uart_puts_P("G0 X15 Y15\n");
//~ get_grbl_response();
//~ uart_puts_P("G1 Z-1\n");
//~ get_grbl_response();
//~ uart_puts_P("G2 X25 Y25 I10\n");
//~ get_grbl_response();
//~ uart_puts_P("G0 Z1\n");
//~ get_grbl_response();
//~ uart_puts_P("G0 X35 Y15\n");
//~ get_grbl_response();
//~ uart_puts_P("G1 Z-1\n");
//~ get_grbl_response();
//~ uart_puts_P("G2 X25 Y5 I-10\n");
//~ get_grbl_response();
//~ uart_puts_P("G0 Z1\n");
//~ get_grbl_response();
//~ uart_puts_P("G0 X15 Y15\n");
//~ get_grbl_response();
//~ uart_puts_P("M5\n");
//~ get_grbl_response();
//~ uart_puts_P("M30\n");
*/
int main(void)
{
stdout = &mystdout;
//uart_init(UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU));
uart_init(UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU));
lcd_init(LCD_DISP_ON_CURSOR);
lcd_clrscr();
lcd_gotoxy(0,0);
lcd_puts_P("Needler v0.7\n");
lcd_gotoxy(0,1);
lcd_puts_P(__DATE__" aw");
//Delay for Splash
for(uint8_t i=0;i<160;++i)
_delay_ms(15);
//PD2: IN : Z_DIR
//PD3: IN : Enable/FEED HOLD. 0=betätigt
//PD6: OUT: Relais Pneumatikventil. 1=EIN
DDRD |= _BV(PD6);
PORTD |= _BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5) | _BV(PD7);
//PB1: IN: Z_STEP
PORTB |= _BV(PB1);
lcd_clrscr();
clr_text_buffer();
strncpy(font_name,"rowmans",10);
/*** TIMER0 ***/
OCR0=250;
//CTC = Clear Timer on Compare match S.80
//Normal port operation, OC0 disconnected
//Prescaler=64 -> clk=250kHz
TCCR0 = _BV(WGM01) | _BV(CS01) | _BV(CS00);
//On Compare match Interrupt Enable for timer 0
TIMSK |= _BV(OCIE0);
/** TIMER1 **/
//PWM Phase correct 10bit
//Set OC1A+OC1B on match when upcounting (page 108)
//TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(COM1A0) | _BV(COM1B0) | _BV(WGM11) | _BV(WGM10);
//Prescaler = 1 (page 110)
//TCCR1B = _BV(CS10);
/** TIMER1 **/
//External clock source on T1 pin. Clock on rising edge.
TCCR1B = _BV(CS12) | _BV(CS11) | _BV(CS10);
//OCR1x=5;
/** External Interrupt INT0 PD2 **/
//Any logical change on INT0 generates an interrupt request.
MCUCR = _BV(ISC00);
GICR = _BV (INT0);
//enable global interrupts
sei();
uint8_t debounce_key=0, last_key=0;
uint8_t key, event=0;
for (;;) /* main event loop */
{
key=key_get();
if(key==last_key)
//.........这里部分代码省略.........
开发者ID:Andy1978,项目名称:needler,代码行数:101,代码来源:main.c
示例13: cli
void HardwareSerial::flush()
{
cli();
_rxfifo->idx_r = _rxfifo->idx_w = 0;
sei();
}
开发者ID:Lohmatyi86,项目名称:rogue-code,代码行数:6,代码来源:HardwareSerial.cpp
示例14: ioinit
/*
* Do all the startup-time peripheral initializations.
*/
static void
ioinit(void)
{
uint16_t pwm_from_eeprom;
/*
* Set up the 16-bit timer 1.
*
* Timer 1 will be set up as a 10-bit phase-correct PWM (WGM10 and
* WGM11 bits), with OC1A used as PWM output. OC1A will be set when
* up-counting, and cleared when down-counting (COM1A1|COM1A0), this
* matches the behaviour needed by the STK500's low-active LEDs.
* The timer will runn on full MCU clock (1 MHz, CS10 in TCCR1B).
*/
TCCR1A = _BV(WGM10) | _BV(WGM11) | _BV(COM1A1) | _BV(COM1A0);
TCCR1B = _BV(CS10);
OCR1A = 0; /* set PWM value to 0 */
/* enable pull-ups for pushbuttons */
CONTROL_PORT = _BV(TRIGGER_DOWN) | _BV(TRIGGER_UP) | _BV(TRIGGER_ADC);
/*
* Enable Port D outputs: PD6 for the clock output, PD7 for the LED
* flasher. PD1 is UART TxD but not DDRD setting is provided for
* that, as enabling the UART transmitter will automatically turn
* this pin into an output.
*/
CONTROL_DDR = _BV(CLOCKOUT) | _BV(FLASH);
/*
* As the location of OC1A differs between supported MCU types, we
* enable that output separately here. Note that the DDRx register
* *might* be the same as CONTROL_DDR above, so make sure to not
* clobber it.
*/
PWMDDR |= _BV(PWMOUT);
UCSRA = _BV(U2X); /* improves baud rate error @ F_CPU = 1 MHz */
UCSRB = _BV(TXEN)|_BV(RXEN)|_BV(RXCIE); /* tx/rx enable, rx complete intr */
UBRRL = (F_CPU / (8 * 9600UL)) - 1; /* 9600 Bd */
/*
* enable ADC, select ADC clock = F_CPU / 8 (i.e. 125 kHz)
*/
ADCSRA = _BV(ADEN) | _BV(ADPS1) | _BV(ADPS0);
TIMSK = _BV(TOIE1);
sei(); /* enable interrupts */
/*
* Enable the watchdog with the largest prescaler. Will cause a
* watchdog reset after approximately 2 s @ Vcc = 5 V
*/
wdt_enable(WDTO_2S);
/*
* Read the value from EEPROM. If it is not 0xffff (erased cells),
* use it as the starting value for the PWM.
*/
if ((pwm_from_eeprom = eeprom_read_word(&ee_pwm)) != 0xffff)
OCR1A = (pwm = pwm_from_eeprom);
}
开发者ID:fffaraz,项目名称:Introduction-to-Microprocessors,代码行数:66,代码来源:largedemo.c
示例15: main
int main( )
{
uint8_t frame;
static uint8_t i;
static uint16_t adcT = 0; //ADC Temp
static uint16_t adcP = 0; //ADC Pin
static uint8_t last_timercycle = 0;
cli();
setup_clock();
//1st let's see how fast we can clock the pin.
et_init( MyMAC );
i = 0;
//Assumed setup:
//
// PB2: Disconnect this (I don't know if you can use it at all)
// PB1: TX (From this device, out) Put a 47nF capcaitor in series.
//Enable ADC. (For reading in pin ADC2)
PORTB &= ~_BV(4);
PORTB |= _BV(4);
ADCSRA = _BV(ADEN) | _BV(ADPS1) | _BV(ADPS0) | _BV(ADSC) | _BV(ADATE);
//Enable port B for the WS2812B.
WSDDR |= WSPIN;
WSPORT &= ~WSPIN;
//The burden of configuring the tick timer is on you, the user.
//#188 Creates a clock with period ~4ms. ~3.2ms at 31MHz, ~4.8ms at 20 MHz.
//Making it lower seems to help.
TCCR1 = _BV(CTC1) | _BV(CS13) | _BV(CS12); //HS Clock/2048
OCR1C = 255;
OCR1A = 1;
TIMSK = _BV(OCIE1A);
//Enable Pin Change Interrupt.
//(For if we have some RX data)
PCMSK |= _BV(PCINT0);
GIMSK |= _BV(PCIE);
sei();
OSCCAL = OSCHIGH;
PORTB |= _BV(0);
while(1)
{
if( last_timercycle != timercycle )
{
last_timercycle = timercycle;
//i++;
i = timercycle & 0x0f;
if( i == 0 )
{
ADMUX = 2;
}
if( i == 1 )
{
adcP = ADC;
ADMUX = _BV(REFS1) | 0x0f;
}
if( i == 2 )
{
adcT = ADC;
}
if( i == 14 )
{
frame++;
//How to send a UDP Packet.
cli();
OSCCAL = OSC20;
et_stopop();
et_startsend( 0 );
memset( macfrom, 0xff, 6 );
send_etherlink_header( 0x0800 );
send_ip_header( 0, (unsigned char*)"\xff\xff\xff\xff", 17 ); //UDP Packet to 255.255.255.255
et_push16( 13313 ); //to port
et_push16( 13312 ); //from port
et_push16( 0 ); //length for later
et_push16( 0 ); //csum for later
et_pushpgmstr( PSTR( "TPIN" ) ); //csum for later
et_push16( adcT );
et_push16( adcP );
et_push16( icmp_out );
et_push16( hict );
et_push16( lowct );
util_finish_udp_packet();
OSCCAL = OSCHIGH;
sei();
i = 0;
//.........这里部分代码省略.........
开发者ID:QrackEE,项目名称:ethertiny,代码行数:101,代码来源:test.c
示例16: debug_led
//.........这里部分代码省略.........
extern uint8_t __heap_start; /* not _end because of .bufferpool */
extern uint8_t __stack;
uint16_t StackCount(void)
{
const uint8_t *p = &__heap_start;
uint16_t c = 0;
while(*p == STACK_CANARY && p <= &__stack)
{
p++;
c++;
}
return c;
}
#define ADC_CONTEXTS 8
adc_context_t adc_context[ADC_CONTEXTS];
u8 num_adc;
u16 stack_high;
#define DISPAVR_RESET_PIN 4 /* on port B */
int main()
{
u8 mcusr_rst = MCUSR;
MCUSR = 0;
wdt_disable();
wdt_enable(WDTO_2S);
/* Disable JTAG so the ADC pins are available.
* Don't do this if the JTAG reset flag is set --
* presumably the jtag pod is connected in that
* case. */
if (! (mcusr_rst & (1<<JTRF)))
{
MCUCR |= (1<<JTD);
}
/* Assert remote AVR reset */
PORTB &= ~(1<<DISPAVR_RESET_PIN);
DDRB |= (1<<DISPAVR_RESET_PIN);
bufferpool_init();
init_persist_data();
systimer_init();
//fuel_gauge_init(&adc_context[num_adc++]);
num_adc = sensors_init(&adc_context[num_adc], num_adc);
adc_init_adc(ADC_DIV128, num_adc, adc_context);
/* Deassert remote AVR reset */
PORTB |= (1<<DISPAVR_RESET_PIN);
spimaster_init();
init_avrms2();
// swuart_init();
/* Enable interrupts */
sei();
/* Populate the tasklist in priority order */
tasklist[num_tasks++] = comms_task_create();
tasklist[num_tasks++] = gps_task_create();
tasklist[num_tasks++] = can_task_create();
tasklist[num_tasks++] = hud_task_create();
// tasklist[num_tasks++] = i2c_task_create();
tasklist[num_tasks++] = gpio_task_create();
//
start_blink_timer();
/* non-preemptive static priority scheduler */
while(1)
{
wdt_reset();
u8 taskidx;
u8 r;
for(taskidx=0; taskidx<num_tasks; taskidx++)
{
r = tasklist[taskidx]->taskfunc();
if (r)
break;
}
if (r == 0)
{
stack_high = StackCount(); /* only run this after all tasks run */
}
}
}
开发者ID:metakevin,项目名称:ms2cluster,代码行数:101,代码来源:main.c
示例17: main
int main (void) {
// disable unused functions for powersaving
PRR = (1<<PRUSI) | (1<<PRUSART);
DDRA = 0xff;
change_clock_prescale( 0x01 ); // full speed 4MHz
led_init_port();
// brownout @1.8V if device is started with insuficcient bats.
if ( mcusr_mirror == (1<<BORF) ) {
blink_red_powersave();
sleep_powerdown();
}
uint8_t i=0; // selected pattern;
uint8_t pwrhyst = 0;
// switch on stepup, change frequency after short delay
POWER_DDR |= (1<<POWER_PIN);
POWER_PORT |= (1<<POWER_PIN);
// bat comparator
ACSR = (1<<ACBG);
DIDR |= (1<<AIN1D);
// init pwm counter
led_init_timer();
key_init_timer_port();
// alive signal
pled_on( (1<<PLED_RED) | (1<<PLED_GREEN) );
led_set_mode_r( 0x11, 0x11, 0 );
_delay_ms(50);
led_set_mode_r( 0x00, 0x00, 0 );
_delay_ms(500);
pled_off( (1<<PLED_RED) );
// check initial bat state for undervolt
if ( (ACSR & (1<<ACO)) ) pwrhyst = 0xFF;
sei();
for(;;) {
for(uint8_t r=0; r< (*light_patterns[i]).rotate; r++) {
// if there is a change to measure with leds off, then here
// => check bat voltage
if ( ACSR & (1<<ACO) ) {
if ( pwrhyst == 0x0f ) {
pled_on( 1<<PLED_RED);
pled_off(1<<PLED_GREEN);
} else {
pwrhyst++;
}
} else {
if ( pwrhyst == 0x00 ) {
pled_on(1<<PLED_GREEN);
pled_off( 1<<PLED_RED);
} else {
pwrhyst--;
}
}
for(uint8_t p=0; p<(*light_patterns[i]).nr_elements; p++) {
if ( key_press & ALL_KEYS ) {
pwrhyst = 0;
led_set_mode_r(0x00,0x00,0);
if( get_key_short( 1<<KEY0 )) {
r = 0;
p = 0;
i++;
if ( i >= sizeof(light_patterns)/sizeof(light_patterns[0]) )
i = 0;
}
if( get_key_long( 1<<KEY0 )) {
pled_off( (1<<PLED_RED) | (1<<PLED_GREEN) );
// wait for key release (with pullup=>1)
loop_until_bit_is_set( KEY_PIN, KEY0 );
sleep_powerdown();
}
} else {
led_set_mode_r(
(*light_patterns[i]->lp_elements)[p]->l12,
(*light_patterns[i]->lp_elements)[p]->l34,
r);
key_wait_times_5ms(
(*light_patterns[i]->lp_elements)[p]->duration
);
}
}
}
}
}
开发者ID:kubroid,项目名称:blinkenkringel,代码行数:93,代码来源:main.c
示例18: main
int main(void)
{
char c;
unsigned short cnt = 0;
#if (F_CPU > 4000000UL)
#define CNTHALLO (unsigned int)(0xFFFF)
#else
#define CNTHALLO (unsigned int)(0xFFFF/3)
#endif
unsigned short mycnt=0;
CLKPR=_BV(CLKPCE);
CLKPR=0;
pir=0;
DDRA |= 0xe2;
PORTA |= 0x81;
adc_init();
softuart_init();
TCCR1A=_BV(COM0B1)|_BV(WGM00);
TCCR1B=_BV(CS00);
softuart_turn_rx_on(); /* redundant - on by default */
sei();
#if WITH_STDIO_DEMO
stdio_demo_func();
#endif
OCR1A=0x10;
OCR1B=0xf0;
for (;;) {
if((PINB&4)==4 ) pir=1;
if ( softuart_kbhit() ) {
c = softuart_getchar();
//softuart_putchar( '[' );
//softuart_putchar( c );
//softuart_putchar( ']' );
if(c=='g')
{
c=softuart_getchar();
if(c==C_ID(ID))
{
softuart_putchar(3);
softuart_putchar(2);
send();
pir=0;
}
}
else if( c=='s')
{
unsigned int pwm;
c=softuart_getchar();
if(c==C_ID(ID))
{
sprintf(line,"made it");
// char line[32];
for(cnt=0;cnt<=31;cnt++)
{
c=softuart_getchar();
if(c=='\n') {line[cnt]=0; break;}
else line[cnt]=c;
}
int ret=sscanf_P(&line[0],PSTR("inTopic/pwm/"STD_ID(ID)" %d"),&pwm);
sprintf_P(dbg,PSTR("%dpwm:%d"),ret,pwm);
OCR1B=pwm;
}
}
}
}
return 0; /* never reached */
}
开发者ID:roman65536,项目名称:Home_auto,代码行数:83,代码来源:main.c
示例19: set_date
void set_date(){
clear_pixelMatrix();
print_date(POS_DATE_SET);
print_year();
print_symbol(16,17, hakenSymb,108,46);
print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() / 2 - 4, POS_DATE_SET - 10);
update_LCD();
int old_selectedItem = 0;
int item = 0;
while (item != 3){
cli();
btn_drehenc_pushed = false;
sei();
while(!btn_drehenc_pushed){
if(rotary != 0){
item += rotary;
cli();
rotary = 0;
sei();
item = item % 4;
if(item<0){
item += 4;
}
switch (old_selectedItem){
case 0: for(int x = 0; x<128; x++){
for(int y = 0; y<10; y++)
reset_pixel(x,y);
} break;
case 1: for(int x = 0; x<128; x++){
for(int y = 0; y<10; y++)
reset_pixel(x,y);
}break;
case 2: for(int x = 0; x<128; x++){
for(int y = 30; y<40; y++)
reset_pixel(x,y);
}break;
case 3: for(int x = 94; x<104; x++){
for(int y = 2+3*15+5; y<2+3*15+5+8; y++)
reset_pixel(x,y);
}break;
}
switch (item) {
case 0: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() / 2 - 4, POS_DATE_SET - 10); break; //-4 = halbe Länge Herz
case 1: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_dateXPos() + get_dayWidth() + get_monthWidth() / 2 - 4, POS_DATE_SET - 10); break;
case 2: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, get_yearXPos() + get_yearWidth() / 2 - 4, YPOS_YEAR - 10);break;
case 3: print_symbol(8, HERZ_KLEIN_WIDTH, herzKleinSymb, 94, 2+3*15+5);break;
}
old_selectedItem = item;
update_LCD();
|
请发表评论