本文整理汇总了C++中Mail::alloc方法的典型用法代码示例。如果您正苦于以下问题:C++ Mail::alloc方法的具体用法?C++ Mail::alloc怎么用?C++ Mail::alloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail
的用法示例。
在下文中一共展示了Mail::alloc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: line_coding_changed_cb
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: test_mail_full
/** 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: send_thread
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: send_thread
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: sendToMail
// 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: adcISR
// 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;
}
}