Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Lab_6_WaG by
main.cpp@29:0736dfa41aab, 2018-03-22 (annotated)
- Committer:
- phn10
- Date:
- Thu Mar 22 15:39:49 2018 +0000
- Revision:
- 29:0736dfa41aab
- Parent:
- 28:a07b27cc6d13
- Child:
- 31:0dc2b4a3eee6
- Child:
- 32:4fe43fa66ce8
clear comments after merge
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| spm71 | 0:ee6e5c60dd2d | 1 | /****************************************************************************** |
| spm71 | 0:ee6e5c60dd2d | 2 | * EECS 397 |
| spm71 | 0:ee6e5c60dd2d | 3 | * |
| spm71 | 18:0e281922212c | 4 | * Assignment Name: Lab 5: WaG |
| spm71 | 0:ee6e5c60dd2d | 5 | * |
| spm71 | 0:ee6e5c60dd2d | 6 | * Authors: Sam Morrison and Phong Nguyen |
| phn10 | 16:dfa9eb1a808d | 7 | * File name: main.cpp |
| spm71 | 22:09dd6977576b | 8 | * Purpose: Configures the dispaly for 4-digit display or motor control |
| spm71 | 0:ee6e5c60dd2d | 9 | * |
| spm71 | 18:0e281922212c | 10 | * Created: 03/01/2018 |
| spm71 | 22:09dd6977576b | 11 | * Last Modified: 03/08/2018 |
| spm71 | 0:ee6e5c60dd2d | 12 | * |
| spm71 | 0:ee6e5c60dd2d | 13 | ******************************************************************************/ |
| spm71 | 0:ee6e5c60dd2d | 14 | #include "mbed.h" |
| phn10 | 8:d8bc78bda829 | 15 | #include "io_pins.h" |
| phn10 | 8:d8bc78bda829 | 16 | #include "display.h" |
| spm71 | 20:d23bcd97f2c5 | 17 | #include "spi.h" |
| spm71 | 20:d23bcd97f2c5 | 18 | #include "stepper.h" |
| spm71 | 23:3da1d39c1ae9 | 19 | #include "utility.h" |
| spm71 | 0:ee6e5c60dd2d | 20 | #include <stdlib.h> |
| spm71 | 0:ee6e5c60dd2d | 21 | #include <stdio.h> |
| spm71 | 0:ee6e5c60dd2d | 22 | #include <string.h> |
| spm71 | 0:ee6e5c60dd2d | 23 | |
| spm71 | 18:0e281922212c | 24 | SPI wag_spi(MOSI, MISO, SCLK); |
| spm71 | 0:ee6e5c60dd2d | 25 | Serial pc(USBTX, USBRX); |
| spm71 | 25:896dbc85907e | 26 | DigitalIn jog_cw(UI_JOG_RIGHT_BUTTON); |
| spm71 | 25:896dbc85907e | 27 | DigitalIn jog_ccw(UI_JOG_LEFT_BUTTON); |
| spm71 | 23:3da1d39c1ae9 | 28 | DigitalIn my_button(USER_BUTTON); |
| spm71 | 25:896dbc85907e | 29 | DigitalIn start_button(UI_START_BUTTON); |
| spm71 | 25:896dbc85907e | 30 | DigitalIn cal_button(UI_CAL_BUTTON); |
| spm71 | 25:896dbc85907e | 31 | DigitalIn station_select(UI_STATION_SELECT); |
| phn10 | 27:3006f5abc0a5 | 32 | BusOut mux_select(MUX_S0, MUX_S1, MUX_S2, MUX_S3); |
| phn10 | 29:0736dfa41aab | 33 | |
| spm71 | 0:ee6e5c60dd2d | 34 | |
| spm71 | 20:d23bcd97f2c5 | 35 | struct spi_cfg as1107{ |
| spm71 | 20:d23bcd97f2c5 | 36 | SPI_AS1107_ID, |
| spm71 | 20:d23bcd97f2c5 | 37 | DSP_AS1107_NCS, |
| spm71 | 20:d23bcd97f2c5 | 38 | SPI_NO_ID, |
| spm71 | 20:d23bcd97f2c5 | 39 | AS1107_SPI_FREQ, |
| spm71 | 20:d23bcd97f2c5 | 40 | AS1107_SPI_NO_BITS, |
| spm71 | 20:d23bcd97f2c5 | 41 | }; |
| spm71 | 20:d23bcd97f2c5 | 42 | |
| spm71 | 22:09dd6977576b | 43 | |
| spm71 | 0:ee6e5c60dd2d | 44 | int main(void) { |
| spm71 | 20:d23bcd97f2c5 | 45 | initial_setup(as1107); |
| phn10 | 11:6751b9406142 | 46 | char bcd[4]; |
| spm71 | 20:d23bcd97f2c5 | 47 | char input; |
| spm71 | 20:d23bcd97f2c5 | 48 | int display_number; |
| spm71 | 20:d23bcd97f2c5 | 49 | |
| spm71 | 25:896dbc85907e | 50 | //set all digits to zero |
| spm71 | 25:896dbc85907e | 51 | spi_send(as1107 0x0100); |
| spm71 | 25:896dbc85907e | 52 | spi_send(as1107 0x0200); |
| spm71 | 25:896dbc85907e | 53 | spi_send(as1107 0x0300); |
| spm71 | 25:896dbc85907e | 54 | spi_send(as1107 0x0400); |
| spm71 | 25:896dbc85907e | 55 | |
| spm71 | 25:896dbc85907e | 56 | jog_cw.mode(PullUp); |
| spm71 | 25:896dbc85907e | 57 | jog_ccw.mode(PullUp); |
| spm71 | 25:896dbc85907e | 58 | while(1) { |
| spm71 | 25:896dbc85907e | 59 | if (jog_ccw == 0) { |
| spm71 | 25:896dbc85907e | 60 | stp_step(STP_CCW); |
| spm71 | 25:896dbc85907e | 61 | } |
| spm71 | 25:896dbc85907e | 62 | if (jog_cw == 0) { |
| spm71 | 25:896dbc85907e | 63 | stp_step(STP_CW); |
| spm71 | 25:896dbc85907e | 64 | } |
| spm71 | 20:d23bcd97f2c5 | 65 | } |
| spm71 | 25:896dbc85907e | 66 | } |
