示例#1
0
int pb_init_multi(mp_int *characteristic, pb_poly *pb, ...) 
{
    mp_err res = MP_OKAY;      /* Assume ok until proven otherwise */
    int n = 0;                 /* Number of ok inits */
    pb_poly* cur_arg = pb;
    va_list args;

    va_start(args, pb);        /* init args to next argument from caller */
    while (cur_arg != NULL) {
        if (pb_init(cur_arg, characteristic) != MP_OKAY) {
            /* Oops - error! Back-track and mp_clear what we already
               succeeded in init-ing, then return error.
            */
            va_list clean_args;
            
            /* end the current list */
            va_end(args);
            
            /* now start cleaning up */            
            cur_arg = pb;
            va_start(clean_args, pb);
            while (n--) {
                pb_clear(cur_arg);
                cur_arg = va_arg(clean_args, pb_poly*);
            }
            va_end(clean_args);
            res = MP_MEM;
            break;
        }
        n++;
        cur_arg = va_arg(args, pb_poly*);
    }
示例#2
0
int main(void)
{
	SetupHardware();
	CDC_Device_CreateStream(&VirtualSerial_CDC_Interface, &USBSerialStream);
	GlobalInterruptEnable();

	_delay_ms(5000);
	uart_puts("ATI\r");
	_delay_ms(500);

	numbers = eeprom_read_word(( uint16_t *)1);

	for (;;)
	{
		if(ConfigSuccess)
		{
			int16_t b = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);

			if(b > -1)
			{
				if(b == '*')
				{
					iRead = 0;
				}

				if(b == '\r' || b == 0x1A)
				{
					uart_puts("\",129,\"aa\"\r");
					_delay_ms(300);
					bufferLength = 1;

					fputs("ok\r\n", &USBSerialStream);
				}

				if(b == 0x1A)
				{
					if(numbers > iRead)
						pb_clear(iRead +1, numbers);

					numbers = iRead;
					eeprom_write_word((uint16_t*)1, (uint16_t)numbers);
				}

				if(b == '*' || b == '\r')
				{
					iRead++;
					uart_puts("AT+CPBW=");

					char buff[5];
					itoa(iRead, buff, 10);
					uart_puts(buff);
					uart_puts(",\"+48");
				}

				if(b > 47 && b < 58)
				{
					uart_put(b);
				}

				if(b == 0x1B)
					openGate();

				if(b == 'd')
					bDebug = !bDebug;

			}

			CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
			USB_USBTask();
		}
		bufferCheck();

		if(!(PINC && (1 << PC2)))
			PORTB |= (1 << PB5);
		else
			PORTB &= ~(1 << PB5);
	}
}