Ejemplo n.º 1
0
void show_settings(void)
{
    uint8_t *ptr;
    uint8_t i;

    ptr = (uint8_t *) &s;

    for (i = 0; i < 14; i++) {
        snprintf(str_temp, TEMP_LEN, "m%d\n", *ptr++);
        uart1_tx_str(str_temp, strlen(str_temp));
        timer_a0_delay(10000);
    }
}
Ejemplo n.º 2
0
static void uart1_rx_irq(enum sys_message msg)
{
    uint16_t u16;
    uint8_t p;
    uint8_t pga, ch, left = 0, right = 0;
    uint8_t *flash_addr = FLASH_ADDR;
    char *input;
    uint8_t *ptr;
    uint8_t allfine = 0;

    input = (char *)uart1_rx_buf;

    p = input[0];
    if (p > 97) {
        p -= 32;
    }

    if ((p == 63) || (p == M_CMD_HELP)) {       // [h?]
        display_help();
    } else if (p == M_CMD_SHOW) {        // [s]how settings
        show_settings();
        uart1_tx_str("ok\r\n", 4);
    } else if (p == M_CMD_WRITE) {       // [w]rite to flash
        if (str_to_uint16(input, &u16, 1, 1, 1, 3)) {
            if (u16 == 1) {
                flash_addr = SEGMENT_B;
            } else if (u16 == 2) {
                flash_addr = SEGMENT_C;
            } else if (u16 == 3) {
                flash_addr = SEGMENT_D;
            }
            flash_save(flash_addr, (void *)&s, sizeof(s));
            uart1_tx_str("ok\r\n", 4);
        }
    } else if (p == M_CMD_READ) {       // [r]ead from flash
        if (str_to_uint16(input, &u16, 1, 1, 1, 3)) {
            if (u16 == 1) {
                flash_addr = SEGMENT_B;
            } else if (u16 == 2) {
                flash_addr = SEGMENT_C;
            } else if (u16 == 3) {
                flash_addr = SEGMENT_D;
            }
            settings_init(flash_addr);
            uart1_tx_str("ok\r\n", 4);
        }
    } else if (p == M_CMD_MUTE) {       // [m]ute pga
        if (str_to_uint16(input, &u16, 1, 1, 1, 6)) {
            pga = u16;
            pga_set_mute_st(pga, MUTE, 1);
            uart1_tx_str("ok\r\n", 4);
        }
    } else if (p == M_CMD_UNMUTE) {     // [u]nmute pga
        if (str_to_uint16(input, &u16, 1, 1, 1, 6)) {
            pga = u16;
            pga_set_mute_st(pga, UNMUTE, 1);
            uart1_tx_str("ok\r\n", 4);
        }
    } else if (p == M_CMD_VOL) {       // [v]olume set
        if (str_to_uint16(input, &u16, 1, 1, 1, 6)) {
            pga = u16;
            ch = input[2];
            if (str_to_uint16(input, &u16, 3, strlen(input) - 3, 0, 255)) {
                ptr = (uint8_t *) & s.v1_r;
                if (ch == 98) {
                    // 'b' - change both channels
                    right = u16;
                    left = u16;
                    allfine = 1;
                } else if (ch == 114) {
                    // 'r' - only change the right channel
                    right = u16;
                    left = *(ptr + (pga * 2 - 2) + 1);
                    allfine = 1;
                } else if (ch == 108) {
                    // 'l' - only change the left channel
                    right = *(ptr + (pga * 2 - 2));
                    left = u16;
                    allfine = 1;
                }
                if (allfine) {
                    pga_set_volume(pga, right, left, 1, 1);
                    uart1_tx_str("ok\r\n", 4);
                }
            }
        }
    }
    //snprintf(str_temp, TEMP_LEN, "D 0x%x 0x%x 0x%x\r\n", input[0], input[1], input[2]);
    //uart1_tx_str(str_temp, strlen(str_temp));

    uart1_p = 0;
    uart1_rx_enable = 1;
}
Ejemplo n.º 3
0
void display_help(void)
{
    snprintf(str_temp, TEMP_LEN
            "\r\n --- mixer controller ver %d \r\n",
            VERSION);
    uart1_tx_str(str_temp, strlen(str_temp));

    uart1_tx_str("\r\ncommands\r\n", 12);
    uart1_tx_str("v___   set volume\r\n", 19);
    uart1_tx_str(" ||+ volume - [0-255]\r\n", 23);
    uart1_tx_str(" |+- channel - {r,l,b}\r\n", 24);
    uart1_tx_str(" |   r: right, l: left, b: both\r\n", 33);
    uart1_tx_str(" +-- pga ID - [1-6]\r\n", 21);
    uart1_tx_str("     1: front, 2: rear, 3: line-in\r\n", 36);
    uart1_tx_str("     4: spdif, 5: front-rear pan, 6: center and subwoofer\r\n", 59);
    uart1_tx_str("m_     mute pga\r\n", 17);
    uart1_tx_str(" +- pga ID - [1-6]\r\n", 20);
    uart1_tx_str("u_     unmute pga\r\n", 19);
    uart1_tx_str(" +- pga ID - [1-6]\r\n", 20);
    uart1_tx_str("w_     write current settings to flash\r\n", 40);
    uart1_tx_str(" +- location [1-3]\r\n", 20);
    uart1_tx_str("r_     load saved settings from flash\r\n", 39);
    uart1_tx_str(" +- location [1-3]\r\n", 20);
    uart1_tx_str("s      show settings\r\n", 22);
    uart1_tx_str("?      show help\r\n", 18);
}
Ejemplo n.º 4
0
int main(void)
{
    main_init();
    rtca_init();
    timer_a0_init();
    uart0_init();
    sim900_init_messagebus();
    sim900.next_state = SIM900_OFF;

    settings_init(SEGMENT_B, VERSION_BASED);
    //settings_apply();

    m.e = 0x0;
    m.seg[0] = 0x0;
    m.seg_num = 1;

    stat.http_post_version = POST_VERSION;
    stat.fix_id = 1;

    sim900.imei[0] = 0;
    sim900.flags = 0;


    gps_trigger_next = 0;
    gprs_trigger_next = s.gprs_loop_interval;

    rtca_set_next = 0;
    rtc_not_set = 1;
    gps_next_state = MAIN_GPS_IDLE;

    if (s.gps_invalidate_interval > s.gps_loop_interval) {
        s.gps_invalidate_interval = s.gps_loop_interval;
    }
   
    gprs_tx_trig = 0;
    gprs_tx_next = s.gprs_static_tx_interval;

    gprs_blackout_lift = 0;

#ifdef DEBUG_GPS
    uart1_init(9600);
    uart1_tx_str("gps debug state\r\n", 17);
#endif

#ifdef DEBUG_GPRS
    uart0_tx_str("gprs debug state\r\n", 18);
    display_menu();
#endif

#ifdef CALIBRATION
    sys_messagebus_register(&adc_calibration, SYS_MSG_RTC_SECOND);
#else
#ifndef DEBUG_GPRS
    sys_messagebus_register(&schedule, SYS_MSG_RTC_SECOND);
    sys_messagebus_register(&parse_gps, SYS_MSG_UART0_RX);
#else
    sys_messagebus_register(&parse_UI, SYS_MSG_UART0_RX);
#endif
#ifndef DEBUG_GPS
    sys_messagebus_register(&parse_gprs, SYS_MSG_UART1_RX);
#endif

#endif

#ifdef FM24_HAS_SLEEP_MODE
    fm24_sleep();
#endif

    // main loop
    while (1) {
        _BIS_SR(LPM3_bits + GIE);
        //wake_up();
#ifdef USE_WATCHDOG
        // reset watchdog counter
        WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL;
#endif
        // new messages can be sent from within a check_events() call, so 
        // parse the message linked list multiple times
        check_events();
        check_events();
        check_events();

#ifdef FM24_HAS_SLEEP_MODE
        // sleep
        if (fm24_status & FM24_AWAKE) {
            fm24_sleep();
        }
#endif

        // P4.0 and P4.1
        //P4SEL &= ~0x3;
        
        /*
        PMMCTL0_H = 0xA5;
        SVSMHCTL &= ~SVMHE;
        SVSMLCTL &= ~(SVSLE+SVMLE);
        PMMCTL0_H = 0x00;
        */
    }
}