Fakultas Ilmu Komputer UI

Commit 30d934ee authored by Adzkia Aisyah Afrah Hardian's avatar Adzkia Aisyah Afrah Hardian
Browse files

push again

parent 7537666c
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -444,7 +444,7 @@ typedef QueueHandle_t SemaphoreHandle_t;
* \defgroup xSemaphoreGive xSemaphoreGive
* \ingroup Semaphores
*/
#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )
#define xSemaphoreGive( xSemaphore ); xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )
/**
* semphr. h
......
......@@ -15,7 +15,7 @@
/* Define a task */
static portTASK_FUNCTION_PROTO(vBlinkLed0, p_);
static portTASK_FUNCTION_PROTO(vTutupPintu, p_);
static portTASK_FUNCTION_PROTO(vBlinkLed1, q_);
static portTASK_FUNCTION_PROTO(vCounter, r_);
static portTASK_FUNCTION_PROTO(vPushButton1, s_);
......@@ -24,6 +24,25 @@ static portTASK_FUNCTION_PROTO(vPushButton1, s_);
SemaphoreHandle_t xSemaphore;
uint16_t counter = 0;
void PWM_Init_Servo(void)
{
/* Set output */
PORTC.DIR |= PIN0_bm;
/* Set Register */
TCC1.CTRLA = (PIN2_bm) | (PIN0_bm);
TCC1.CTRLB = (PIN4_bm) | (PIN2_bm) | (PIN1_bm);
/* Set Period */
TCC1.PER = 1000;
/* Set Compare Register value*/
TCC1.CCA = 350;
}
int main (void)
{
/* Insert system clock initialization code here (sysclk_init()). */
......@@ -31,13 +50,14 @@ int main (void)
board_init();
pmic_init();
gfx_mono_init();
PWM_Init_Servo();
gpio_set_pin_high(LCD_BACKLIGHT_ENABLE_PIN);
gfx_mono_draw_string("RTOS v10.2.1", 0, 0, &sysfont);
/* Create the task */
xTaskCreate(vBlinkLed0, "", 1000, NULL, tskIDLE_PRIORITY + 1, NULL); // higher priority
xTaskCreate(vTutupPintu, "", 1000, NULL, tskIDLE_PRIORITY + 1, NULL); // higher priority
xTaskCreate(vBlinkLed1, "", 1000, NULL, tskIDLE_PRIORITY + 2, NULL); // higher priority
xTaskCreate(vPushButton1, "", 1000, NULL, tskIDLE_PRIORITY + 3, NULL); // higher priority
xTaskCreate(vCounter, "", 1000, NULL, tskIDLE_PRIORITY, NULL); // low priority
......@@ -51,16 +71,23 @@ int main (void)
vTaskStartScheduler();
}
static portTASK_FUNCTION(vBlinkLed0, p_) {
static portTASK_FUNCTION(vTutupPintu, p_) {
char strbuf[128];
int flagLed0 = 1;
while(1) {
flagLed0 = !flagLed0;
ioport_set_pin_level(LED0_GPIO, flagLed0);
snprintf(strbuf, sizeof(strbuf), "LED 0 : %d", !flagLed0);
gfx_mono_draw_string(strbuf,0, 16, &sysfont);
vTaskDelay(100/portTICK_PERIOD_MS);
snprintf(strbuf, sizeof(strbuf), "Front Door : %s", "UNLOCKED");
gfx_mono_draw_string(strbuf,0, 0, &sysfont);
if(ioport_get_pin_level(GPIO_PUSH_BUTTON_1)==0){
snprintf(strbuf, sizeof(strbuf), "Front Door : %s", "LOCKED");
gfx_mono_draw_string(strbuf,0, 0, &sysfont);
snprintf(strbuf, sizeof(strbuf), "Security Alarm : %s", "ACTIVATED");
gfx_mono_draw_string(strbuf,0, 8, &sysfont);
TCC1.CCA = 1
xSemaphoreGive(xSemaphore);
}
}
}
......@@ -82,7 +109,7 @@ static portTASK_FUNCTION(vPushButton1, s_) {
while(1) {
if(ioport_get_pin_level(GPIO_PUSH_BUTTON_1)==0){
if(ioport_get_pin_level(GPIO_PUSH_BUTTON_2)==0){
if(xSemaphoreTake(xSemaphore, (TickType_t) 10) == pdTRUE) {
counter++;
snprintf(strbuf, sizeof(strbuf), "Counter : %d", counter);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment