Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Wed Oct 10 00:33:53 2018 +0000
Revision:
0:8fdf9a60065b
how to make mbed librry

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kadonotakashi 0:8fdf9a60065b 1 /* events
kadonotakashi 0:8fdf9a60065b 2 * Copyright (c) 2017 ARM Limited
kadonotakashi 0:8fdf9a60065b 3 *
kadonotakashi 0:8fdf9a60065b 4 * Licensed under the Apache License, Version 2.0 (the "License");
kadonotakashi 0:8fdf9a60065b 5 * you may not use this file except in compliance with the License.
kadonotakashi 0:8fdf9a60065b 6 * You may obtain a copy of the License at
kadonotakashi 0:8fdf9a60065b 7 *
kadonotakashi 0:8fdf9a60065b 8 * http://www.apache.org/licenses/LICENSE-2.0
kadonotakashi 0:8fdf9a60065b 9 *
kadonotakashi 0:8fdf9a60065b 10 * Unless required by applicable law or agreed to in writing, software
kadonotakashi 0:8fdf9a60065b 11 * distributed under the License is distributed on an "AS IS" BASIS,
kadonotakashi 0:8fdf9a60065b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kadonotakashi 0:8fdf9a60065b 13 * See the License for the specific language governing permissions and
kadonotakashi 0:8fdf9a60065b 14 * limitations under the License.
kadonotakashi 0:8fdf9a60065b 15 */
kadonotakashi 0:8fdf9a60065b 16
kadonotakashi 0:8fdf9a60065b 17 #include "events/mbed_shared_queues.h"
kadonotakashi 0:8fdf9a60065b 18 #include "mbed.h"
kadonotakashi 0:8fdf9a60065b 19
kadonotakashi 0:8fdf9a60065b 20 using namespace events;
kadonotakashi 0:8fdf9a60065b 21
kadonotakashi 0:8fdf9a60065b 22 namespace mbed {
kadonotakashi 0:8fdf9a60065b 23
kadonotakashi 0:8fdf9a60065b 24 #ifdef MBED_CONF_RTOS_PRESENT
kadonotakashi 0:8fdf9a60065b 25 /* Create an event queue, and start the thread that dispatches it. Static
kadonotakashi 0:8fdf9a60065b 26 * variables mean this happens once the first time each template instantiation
kadonotakashi 0:8fdf9a60065b 27 * is called. This is currently instantiated no more than twice.
kadonotakashi 0:8fdf9a60065b 28 */
kadonotakashi 0:8fdf9a60065b 29 template
kadonotakashi 0:8fdf9a60065b 30 <osPriority Priority, size_t QueueSize, size_t StackSize>
kadonotakashi 0:8fdf9a60065b 31 EventQueue *do_shared_event_queue_with_thread()
kadonotakashi 0:8fdf9a60065b 32 {
kadonotakashi 0:8fdf9a60065b 33 static uint64_t queue_buffer[QueueSize / sizeof(uint64_t)];
kadonotakashi 0:8fdf9a60065b 34 static EventQueue queue(sizeof queue_buffer, (unsigned char *) queue_buffer);
kadonotakashi 0:8fdf9a60065b 35
kadonotakashi 0:8fdf9a60065b 36 static uint64_t stack[StackSize / sizeof(uint64_t)];
kadonotakashi 0:8fdf9a60065b 37 static Thread thread(Priority, StackSize, (unsigned char *) stack);
kadonotakashi 0:8fdf9a60065b 38
kadonotakashi 0:8fdf9a60065b 39 Thread::State state = thread.get_state();
kadonotakashi 0:8fdf9a60065b 40 if (state == Thread::Inactive || state == Thread::Deleted) {
kadonotakashi 0:8fdf9a60065b 41 osStatus status = thread.start(callback(&queue, &EventQueue::dispatch_forever));
kadonotakashi 0:8fdf9a60065b 42 MBED_ASSERT(status == osOK);
kadonotakashi 0:8fdf9a60065b 43 if (status != osOK) {
kadonotakashi 0:8fdf9a60065b 44 return NULL;
kadonotakashi 0:8fdf9a60065b 45 }
kadonotakashi 0:8fdf9a60065b 46 }
kadonotakashi 0:8fdf9a60065b 47
kadonotakashi 0:8fdf9a60065b 48 return &queue;
kadonotakashi 0:8fdf9a60065b 49 }
kadonotakashi 0:8fdf9a60065b 50 #endif
kadonotakashi 0:8fdf9a60065b 51
kadonotakashi 0:8fdf9a60065b 52 EventQueue *mbed_event_queue()
kadonotakashi 0:8fdf9a60065b 53 {
kadonotakashi 0:8fdf9a60065b 54 #if MBED_CONF_EVENTS_SHARED_DISPATCH_FROM_APPLICATION || !defined MBED_CONF_RTOS_PRESENT
kadonotakashi 0:8fdf9a60065b 55 /* Only create the EventQueue, but no dispatching thread */
kadonotakashi 0:8fdf9a60065b 56 static unsigned char queue_buffer[MBED_CONF_EVENTS_SHARED_EVENTSIZE];
kadonotakashi 0:8fdf9a60065b 57 static EventQueue queue(sizeof queue_buffer, queue_buffer);
kadonotakashi 0:8fdf9a60065b 58
kadonotakashi 0:8fdf9a60065b 59 return &queue;
kadonotakashi 0:8fdf9a60065b 60 #else
kadonotakashi 0:8fdf9a60065b 61 return do_shared_event_queue_with_thread<osPriorityNormal, MBED_CONF_EVENTS_SHARED_EVENTSIZE, MBED_CONF_EVENTS_SHARED_STACKSIZE>();
kadonotakashi 0:8fdf9a60065b 62 #endif
kadonotakashi 0:8fdf9a60065b 63 }
kadonotakashi 0:8fdf9a60065b 64
kadonotakashi 0:8fdf9a60065b 65 #ifdef MBED_CONF_RTOS_PRESENT
kadonotakashi 0:8fdf9a60065b 66 EventQueue *mbed_highprio_event_queue()
kadonotakashi 0:8fdf9a60065b 67 {
kadonotakashi 0:8fdf9a60065b 68 return do_shared_event_queue_with_thread<osPriorityHigh, MBED_CONF_EVENTS_SHARED_HIGHPRIO_EVENTSIZE, MBED_CONF_EVENTS_SHARED_HIGHPRIO_STACKSIZE>();
kadonotakashi 0:8fdf9a60065b 69 }
kadonotakashi 0:8fdf9a60065b 70 #endif
kadonotakashi 0:8fdf9a60065b 71
kadonotakashi 0:8fdf9a60065b 72 }