예제 #1
0
파일: main.c 프로젝트: GDXN/MicroModem
// Simple initialization function.
static void init(void)
{
    // Enable interrupts
    IRQ_ENABLE;

    // Initialize hardware timers
    timer_init();

    // Initialize serial comms on UART0,
    // which is the hardware serial on arduino
    ser_init(&ser, SER_UART0);
    ser_setbaudrate(&ser, 9600);

    // For some reason BertOS sets the serial
    // to 7 bit characters by default. We set
    // it to 8 instead.
    UCSR0C = _BV(UCSZ01) | _BV(UCSZ00);

    // Create a modem context
    afsk_init(&afsk, ADC_CH);
    // ... and a protocol context with the modem
    mp1Init(&mp1, &afsk.fd, mp1Callback);

    // That's all!
}
예제 #2
0
파일: afsk_test.c 프로젝트: DINKIN/tnc1
int afsk_testSetup(void)
{
	kdbg_init();
	kfiledebug_init(&dbg);
	fp_adc = afsk_fileOpen("test/afsk_test.au");
	#if CPU_AVR
		#warning TODO: open the file?
	#else
		fp_dac = fopen("test/afsk_test_out.au", "w+b");
	#endif
	ASSERT(fp_dac);
	#define FS_HH (((uint32_t)CONFIG_AFSK_DAC_SAMPLERATE) >> 24)
	#define FS_HL ((((uint32_t)CONFIG_AFSK_DAC_SAMPLERATE) >> 16) & 0xff)
	#define FS_LH ((((uint32_t)CONFIG_AFSK_DAC_SAMPLERATE) >> 8) & 0xff)
	#define FS_LL (((uint32_t)CONFIG_AFSK_DAC_SAMPLERATE) & 0xff)

	uint8_t snd_header[] = { '.','s','n','d', 0,0,0,24, 0,0,0,0, 0,0,0,2, FS_HH,FS_HL,FS_LH,FS_LL, 0,0,0,1};

	ASSERT(fwrite(snd_header, 1, sizeof(snd_header), fp_dac) == sizeof(snd_header));

	timer_init();
	afsk_init(&afsk_fd, 0 ,0);
	ax25_init(&ax25, &afsk_fd.fd, message_hook);
	return 0;
}
예제 #3
0
파일: main.c 프로젝트: fantasea/APRS
static void init(void)
{
	/* Enable all the interrupts */
	IRQ_ENABLE;

	/* Initialize debugging module (allow kprintf(), etc.) */
	kdbg_init();
	/* Initialize system timer */
	timer_init();
	/* Initialize LED driver */
	LED_INIT();

	ser_init(&ser_port, SER_UART2);
	ser_setbaudrate(&ser_port, 115200L);

	afsk_init(&afsk, 0, 0);

	// timer period = 24000000 hz /100/25 = 9600hz
	AD_Init(&afsk);
	AD_SetTimer(100, 25);
	AD_Start();

	DA_Init(&afsk);
	DA_SetTimer(100, 25);

	kiss_init(&ser_port, &ax25, &afsk);

	ax25_init(&ax25, &afsk.fd, 1, ax25_message_callback);
}
예제 #4
0
파일: main.c 프로젝트: mobilinkd/tnc1
/**
 * Initialize the module.  Initialize the following subsystems:
 *
 * - kernel debugging
 * - timer
 * - serial UART0
 * - Bluetooth module
 * - AFSK driver
 * - KISS driver
 *
 * The AFSK module should be initialized after the startup banner is
 * printed to reduce the chance of a buffer overrun.
 */
static void init(void)
{
    IRQ_ENABLE;
    kdbg_init();
    timer_init();

    power_on();

    int hc_status = init_hc05(&ser.fd);

    wdt_location = 0;

    mobilinkd_set_error(MOBILINKD_ERROR_WATCHDOG_TIMEOUT);

    afsk_init(&afsk, ADC_CH, 0);

    wdt_location = 1;

    kiss_init(&kiss, &afsk.fd, &ser.fd);
    wdt_location = 2;

    if (kiss.params.options & KISS_OPTION_VIN_POWER_ON)
    {
        set_power_config(get_power_config() | POWER_ON_VIN_ON);
    }
    if (kiss.params.options & KISS_OPTION_VIN_POWER_OFF)
    {
        set_power_config(get_power_config() | POWER_OFF_VIN_OFF);
    }

    if (kiss.params.options & KISS_OPTION_PTT_SIMPLEX)
    {
        afsk_ptt_set(&afsk, AFSK_PTT_MODE_SIMPLEX);
    }
    else
    {
        afsk_ptt_set(&afsk, AFSK_PTT_MODE_MULTIPLEX);
    }

    power_on_message(hc_status);
    enable_power_off();

    wdt_enable(WDTO_4S);
}
예제 #5
0
파일: main.c 프로젝트: DINKIN/bertos
static void init(void)
{
	IRQ_ENABLE;
	kdbg_init();
	timer_init();

	/*
	 * Init afsk demodulator. We need to implement the macros defined in hw_afsk.h, which
	 * is the hardware abstraction layer.
	 * We do not need transmission for now, so we set transmission DAC channel to 0.
	 */
	afsk_init(&afsk, ADC_CH, 0);
	/*
	 * Here we initialize AX25 context, the channel (KFile) we are going to read messages
	 * from and the callback that will be called on incoming messages.
	 */
	ax25_init(&ax25, &afsk.fd, message_callback);

	/* Initialize serial port, we are going to use it to show APRS messages*/
	ser_init(&ser, SER_UART0);
	ser_setbaudrate(&ser, 115200L);
}
예제 #6
0
파일: main.c 프로젝트: shawnchain/aprs
static void init(void)
{

    IRQ_ENABLE;

	kdbg_init();
	timer_init();

	/* Initialize serial port, we are going to use it to show APRS messages*/
	ser_init(&g_serial, SER_UART0);
	ser_setbaudrate(&g_serial, SER_DEFAULT_BAUD_RATE);
    // For some reason BertOS sets the serial
    // to 7 bit characters by default. We set
    // it to 8 instead.
    UCSR0C = _BV(UCSZ01) | _BV(UCSZ00); // see ATMEGA328P datasheet P197, Table 20-11. UCSZn Bits Settings

    // initialize the reader that wraps the serial
    serialreader_init(&g_serialreader, &g_serial);

    // Load settings first
    settings_load();

	/*
	 * Init afsk demodulator. We need to implement the macros defined in hw_afsk.h, which
	 * is the hardware abstraction layer.
	 * We do not need transmission for now, so we set transmission DAC channel to 0.
	 */
	afsk_init(&g_afsk, ADC_CH, DAC_CH);

	/*
	 * Here we initialize AX25 context, the channel (KFile) we are going to read messages
	 * from and the callback that will be called on incoming messages.
	 */
	ax25_init(&g_ax25, &g_afsk.fd, ax25_msg_callback);
	g_ax25.pass_through = false;

	// Initialize the kiss module
	// NOTE - use shared memory buffer
#if MOD_KISS
	kiss_init(&g_serialreader,&g_ax25);
#endif

#if MOD_BEACON
	// Initialize the beacon module
    beacon_init(beacon_mode_exit_callback);
#endif

    // Initialize the digi module
#if MOD_DIGI
    digi_init();
#endif

#if MOD_RADIO
    // Initialize the soft serial and radio
    radio_init(4310400); //TODO read from settings
#endif

    // Initialize GPS NMEA/GPRMC parser
#if MOD_TRACKER
    tracker_init();
#endif

#if MOD_CONSOLE
    //////////////////////////////////////////////////////////////
    // Initialize the console & commands
    console_init();
    console_add_command(PSTR("MODE"),cmd_switch_mode);			// setup tnc run mode
#if MOD_KISS
    console_add_command(PSTR("KISS"),cmd_enter_kiss_mode);		// enable KISS mode
#endif
#endif
}