コード例 #1
0
ファイル: main.cpp プロジェクト: 0xc0170/mbed
void line_coding_changed_cb(int baud, int bits, int parity, int stop)
{
    line_coding_t *lc = lc_mail.alloc();
    lc->baud = baud;
    lc->bits = bits;
    lc->parity = parity;
    lc->stop = stop;
    lc_mail.put(lc);
}
コード例 #2
0
ファイル: main.cpp プロジェクト: betzw/mbed
/** Test mail empty

    Given a mail of uint32_t data with size of 1
    before data is inserted the mail shouldn't be full
    after data is inserted the mail should be full
 */
void test_mail_full()
{
    Mail<mail_t, 1> m;

    mail_t *mail = m.alloc();

    TEST_ASSERT_EQUAL(false,  m.full());

    m.put(mail);

    TEST_ASSERT_EQUAL(true, m.full());
}
コード例 #3
0
ファイル: main.cpp プロジェクト: 3eggert/mbed
void send_thread (void const *argument) {
    uint32_t i = 0;
    while (true) {
        i++; // fake data update
        mail_t *mail = mail_box.alloc();
        mail->voltage = (i * 0.1) * 33; 
        mail->current = (i * 0.1) * 11;
        mail->counter = i;
        mail_box.put(mail);
        Thread::wait(1000);
    }
}
コード例 #4
0
ファイル: main.cpp プロジェクト: AlessandroA/mbed
void send_thread (void const *argument) {
    static uint32_t i = 10;
    while (true) {
        i++; // fake data update
        mail_t *mail = mail_box.alloc();
        mail->voltage = CREATE_VOLTAGE(i);
        mail->current = CREATE_CURRENT(i);
        mail->counter = i;
        mail_box.put(mail);
        Thread::wait(QUEUE_PUT_DELAY);
    }
}
コード例 #5
0
ファイル: main.cpp プロジェクト: rm32/Lab3
// Send speed, accelerometer and brake values to a 100 element MAIL queue
// car mail semaphore used to protect messages
// average speed and input semphore used to fix vales
// Repetition rate 0.2 Hz = 5 seconds
void sendToMail(void const *args){
    while(true){
        mail_t *mail = mail_box.alloc();
        CAR_MAIL_SEM.wait();

        AVR_SPEED_SEM.wait();
        mail->speedVal = averageSpeed; 
        AVR_SPEED_SEM.release();
        
        INPUT_SEM.wait();
        mail->accelerometerVal = accelerationValue;
        mail->breakVal = brakeValue;
        INPUT_SEM.release();
        
        write++;        
       
        mail_box.put(mail);
                
        CAR_MAIL_SEM.release();
                
        Thread::wait(5000);  
    }
}
コード例 #6
0
ファイル: main.cpp プロジェクト: SoCM/ELEC143
// Call this on precise intervals
void adcISR() {

    
    //Read sample - make a copy
    float sample = adcIn;
    //Grab switch state
    uint32_t switch1State = sw1;
    uint32_t switch2State = sw2;
    
    //Allocate a block from the memory pool
    message_t *message = mail_box.alloc();
    if (message == NULL) {
        //Out of memory
        printf("Out of memory\n\r");
        redLED = 1;
        return;   
    }
    
    //Fill in the data
    message->adcValue = sample;
    message->sw1State = switch1State;
    message->sw2State = switch2State;
    
    //Write to queue
    osStatus stat = mail_box.put(message);    //Note we are sending the "pointer"
    
    //Check if succesful
    if (stat == osErrorResource) {
        redLED = 1; 
        printf("queue->put() Error code: %4Xh, Resource not available\r\n", stat);   
        mail_box.free(message);
        return;
    }
    
    
}