Basic driver working

Committer:
f3d
Date:
Mon Feb 01 14:22:38 2021 +0000
Revision:
79:a022f7789a49
Parent:
77:9140e10d79ee
Child:
80:ff42f77928ad
Pin assignment done

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hyungo 77:9140e10d79ee 1 /* SDT-example-blinky
hyungo 77:9140e10d79ee 2 *
hyungo 77:9140e10d79ee 3 * Copyright (c) 2018 Sigma Delta Technologies Inc.
hyungo 77:9140e10d79ee 4 *
hyungo 77:9140e10d79ee 5 * MIT License
hyungo 77:9140e10d79ee 6 *
hyungo 77:9140e10d79ee 7 * Permission is hereby granted, free of charge, to any person
hyungo 77:9140e10d79ee 8 * obtaining a copy of this software and associated documentation
hyungo 77:9140e10d79ee 9 * files (the "Software"), to deal in the Software without
hyungo 77:9140e10d79ee 10 * restriction, including without limitation the rights to use,
hyungo 77:9140e10d79ee 11 * copy, modify, merge, publish, distribute, sublicense, and/or sell
hyungo 77:9140e10d79ee 12 * copies of the Software, and to permit persons to whom the
hyungo 77:9140e10d79ee 13 * Software is furnished to do so, subject to the following
hyungo 77:9140e10d79ee 14 * conditions:
hyungo 77:9140e10d79ee 15 *
hyungo 77:9140e10d79ee 16 * The above copyright notice and this permission notice shall be
hyungo 77:9140e10d79ee 17 * included in all copies or substantial portions of the Software.
hyungo 77:9140e10d79ee 18 *
hyungo 77:9140e10d79ee 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
hyungo 77:9140e10d79ee 20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
hyungo 77:9140e10d79ee 21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
hyungo 77:9140e10d79ee 22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
hyungo 77:9140e10d79ee 23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
hyungo 77:9140e10d79ee 24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
hyungo 77:9140e10d79ee 25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
hyungo 77:9140e10d79ee 26 * OTHER DEALINGS IN THE SOFTWARE.
hyungo 77:9140e10d79ee 27 */
hyungo 77:9140e10d79ee 28
Jonathan Austin 0:2757d7abb7d9 29 #include "mbed.h"
Jonathan Austin 0:2757d7abb7d9 30
hyungo 77:9140e10d79ee 31 /* Serial */
hyungo 77:9140e10d79ee 32 #define BAUDRATE 9600
f3d 79:a022f7789a49 33 Serial g_Serial_pc(P0_18, P0_14, BAUDRATE);
hyungo 77:9140e10d79ee 34
hyungo 77:9140e10d79ee 35 /* DigitalOut */
hyungo 77:9140e10d79ee 36 #define LED_ON 0
hyungo 77:9140e10d79ee 37 #define LED_OFF 1
f3d 79:a022f7789a49 38 //DigitalOut g_DO_LedRed(LED_RED, LED_OFF);
f3d 79:a022f7789a49 39 //DigitalOut g_DO_LedGreen(LED_GREEN, LED_OFF);
f3d 79:a022f7789a49 40 //DigitalOut g_DO_LedBlue(LED_BLUE, LED_OFF);
f3d 79:a022f7789a49 41 DigitalOut g_DO_LedBlue(A5, LED_OFF);
f3d 79:a022f7789a49 42 //mosi,miso,clk,ss
f3d 79:a022f7789a49 43 SPI spi(P0_25,P0_26,P0_27,P0_28);
f3d 79:a022f7789a49 44 DigitalOut Rst(P0_21);
f3d 79:a022f7789a49 45 DigitalOut DC(P0_20);
hyungo 77:9140e10d79ee 46 int main(void) {
f3d 79:a022f7789a49 47 spi.format(8, 3);
f3d 79:a022f7789a49 48 spi.frequency(1000000);
f3d 79:a022f7789a49 49
hyungo 77:9140e10d79ee 50 while(true) {
f3d 79:a022f7789a49 51 //g_Serial_pc.printf("LED Toggle\r\n");
f3d 79:a022f7789a49 52 spi.write(0xa5);
hyungo 77:9140e10d79ee 53 g_DO_LedBlue = !g_DO_LedBlue;
f3d 79:a022f7789a49 54 wait(0.1); // 1sec
Jonathan Austin 0:2757d7abb7d9 55 }
hyungo 77:9140e10d79ee 56
hyungo 77:9140e10d79ee 57 return 0;
Jonathan Austin 0:2757d7abb7d9 58 }