点击文件名下载附件
! k! r2 N) `& V, z
目录Table of Contents0 p/ i1 {- I4 _& n7 X2 E6 P
ARM® Cortex® M4 Cookbook! s9 M( V0 O* ^$ S& A. n
Credits " M$ U9 L" l# ~3 `: f9 V* E1 x( QAbout the Author % }, O8 K G- {& QAbout the Reviewer : e6 x! G4 }5 H$ qwww.PacktPub.com5 A! G# ?/ H! [5 \
eBooks, discount offers, and more" h4 U. O: W7 Z! S6 r: K$ P) |' ?
Why Subscribe? . J6 y: y2 h- ^" g( T/ X5 `Preface- }5 g" C7 l+ U4 U8 N) A" _' z
What this book covers: O4 L1 q, A. f/ P! U& g$ G. f
What you need for this book8 ?2 Y: F: Y$ H4 |
Who this book is for1 D8 w3 x( j; E7 s) I( q- x
Sections # j3 s" i/ W! V% M' C: CGetting ready - Z: {$ W" H( g! `( O+ xHow to do it…4 H! ]; |6 N8 A+ D8 k4 c
How it works… : Y" o3 ^% ^- j' a, T" E0 [2 H. UThere's more…4 A4 g4 l4 Y* X7 G3 S
See also5 b* @5 S* C9 D% k. w
Conventions 7 S% @) `& V. Z3 B- k6 A( J2 ~6 L( |Reader feedback 5 b& w- i3 B+ J2 UCustomer support+ O3 g0 z( Z% m
Downloading the example code0 V3 @; q, g0 Z G4 i0 A7 J
Downloading the color images of this book + v) Z# O m2 N$ v# x. fErrata) ^. B$ ^3 k( }* C2 B: c Z: i
Piracy t4 Q. Y, X4 S0 f/ pQuestions+ v1 \0 L* Q8 w2 }% u
1. A Practical Introduction to ARM® CORTEX®4 j& W2 n' p* z; |6 I2 d3 O% p
Introduction3 `- C+ c9 ~5 Y/ O+ M0 e
Installing uVision54 q! y. V0 T9 m2 H4 x L
How to do it… , {5 g) h. l' p1 Y2 N8 m+ hHow it works… 4 P+ X0 _; }0 aLinking an evaluation board 8 N1 a! X h+ y3 S DHow to do it…9 J8 r d; i+ v) V# C& w0 V [! K
How it works…% d# k" ^$ f! [6 m' ~0 H
There's more…! L' b, t7 ~# ~% I. h
Running an example program* F: p' E" H* z# t. q( S
How to do it… 8 a. J& G& N; ^0 OHow it works…/ f2 f6 y: L9 P( P7 X! H" x
Writing a simple program 7 R" S% \/ `- f+ d. G+ }How to do it…; o0 }& C! k3 B$ ^$ ^
How it works… . Y L- p8 I% _% p6 P y2 kThere's more… 0 ^6 u# w$ M) P6 H. e g; h0 RUnderstanding the simple use of GPIO' h& G9 k2 j% \; J# C- Y/ v
How to do it… ) D! M: x, T0 ` G- PHow it works… , O/ B; t) {2 F0 WThere's more… ; J. ~; c+ W7 wEstimating microcontroller performance 0 b' @# \' s2 b% M# }How to do it… . f/ K0 H3 _, k4 ~2 FThere's more…5 Z* H3 B1 F6 c) G5 Q( D+ q" ~8 y
See also g0 H% D$ E$ V: R
2. C Language Programming - y: o/ Q: g8 DIntroduction& q. |- G; X0 b, g
Configuring the hardware abstraction layer$ ?. Y5 [- h7 f/ n9 o N
How to do it… 1 R2 p2 O/ `5 M- e& wHow it works…6 Z: ]" a1 q/ l H
Writing a C program to blink each LED in turn + K; q% y1 V. r% D; n) hGetting ready…$ A9 t8 I. Y9 @1 @- J0 N
How to do it… - C* _4 y; V4 R6 w4 B5 ^# kHow it works…2 Z2 Z# D; K3 F3 g( F
There's more… + h4 S- |7 g1 Q) d) g L9 AWriting a function 0 J4 Z8 L* ?6 D2 t& j, `How to do it ' ^9 F- r% G( U8 u! bHow it works…7 o) Z6 H, Y4 f4 [: Y( c v
There's more…7 R i3 U: E' e% N" Y, z+ C' u* `
Writing to the console window - e; w6 h1 b+ \+ ]Getting ready 4 U6 j( w9 t: }: C- Z( x' P, sHow to do it…6 [/ p& [# q( a3 b e
How it works… * M+ N9 h' j5 Z; iWriting to the GLCD3 M- Q. _) ?) ?+ L
Getting ready 8 K+ ]% v( g a( K/ R) |1 @How to do it… * W8 Z K' |9 }3 n. X3 JHow it works… + T' c# L+ x1 s8 r+ NCreating a game application – Stage 1 3 B( U7 P2 J H8 kHow to do it… : D: }; `7 E7 M7 \8 aHow it works… 2 Z" H3 C7 ^, R" H& b4 oCreating a game application – Stage 2$ \3 y5 x+ H9 d3 }4 w
There's more… : ~- S6 q- i8 OHow it works…. E5 u, F$ ] b* J. s4 T
Debugging your code using print statements G! d- H8 |& Y1 ^. p7 C( e& r& Q
How to do it…4 [, }3 ]$ L( ?" i/ r+ {% |1 N
How it works…# b1 G& b& j- d/ ]
Using the debugger% ~5 \ R2 U5 \
How to do it… _/ `% R* r! v. n
See also & A8 e6 b- \+ k5 V3. Programming I/O / f X( S$ _4 D- e" e8 c. @6 zIntroduction # O6 c) Y9 B k0 g% P/ hPerforming arithmetic operations5 H8 V+ x: B; {
How to do it…: m s( _* M, h/ v5 g3 |
How it works…! u& }. n; d, j4 H
Illustrating machine storage classes & O B; @: N, k" DHow to do it… & x- O7 S }' h$ U/ ?0 DHow it works… . k4 }0 P9 F4 Z' p/ m9 o/ eConfiguring GPIO ports: k J& u5 ^/ u
How to do it… , f" O' D: @6 R% v/ g& dHow it works… . c3 n7 `2 G4 D% x* fThere's more… # J% q" @( x; K) s5 v/ Z# UConfiguring UART ports ( g$ ]7 g O% b! JHow to do it… 7 d [$ J- L( F# Z8 uHow it works…, G+ ]! `0 E( z
Handling interrupts " _. g- ]: \, S6 H* ~, sGetting ready " {( j, e0 }. Y; tHow to do it…# ]: r. h* Y ? n1 _1 U. b" Q
How it works…4 | h7 {; u5 [+ H
There's more… 8 D, @; d& T. [$ J, D3 ^Using timers to create a digital clock6 m+ J; n4 e' q7 a/ e# k
How to do it… # K7 R+ ]6 A! T: S3 D3 x+ iHow it works…$ o( u/ N" X( |
4. Assembly Language Programming 3 Y/ t8 `9 T: w$ q6 OIntroduction( [8 n" u9 V5 [! E0 D
Writing Cortex-M4 assembly language# T4 f, {) O$ M6 ?# i
Getting ready Z" h2 I$ Z1 i2 ]/ A
How to do it… - j3 f/ Z4 u5 {7 z0 KHow it works…. t9 d* I0 C2 m2 O1 z: \( B! k
There's more… " N0 X- T, A: G* \See also7 K0 s1 W! Q( H8 x3 I ?9 F# t
Passing parameters between C and the assembly language ) b) \+ D2 ?/ uGetting ready 2 ^) ^8 \, F. p% j9 A6 g& P" }How to do it…) ^0 Z; A. n' X4 [, c
How it works… # G" @6 E: P5 kThere's more… 8 i+ M f1 z, b, ]0 qSee also) J s$ g4 i4 _0 ]% ]7 m. t. J8 Q
Handling interrupts in assembly language0 b a7 K# r) ^' r! E
Getting ready8 ~! l: \6 k& W6 ^ g! x) P; ?0 X
How to do it… - V& p- m' K6 y7 L6 I4 O, MHow it works… ; W% Z# o* h$ }6 [7 QThere's more…5 @; q4 G8 m$ f! n: J& M7 r* f) K7 E
Implementing a jump table / N! g2 d; o8 S2 @0 \8 e, s1 |Getting ready # I: A7 e$ L% E) MHow to do it…6 c# P) ?6 s* u' L- K
How it works…' R1 J* X& U: ^' @, m7 Z/ _
Debugging assembly language9 Q6 y5 c! J X, F6 a9 Q5 H
How to do it… - p" S5 w- y: i# }; Z# g1 Q5 N) _How it works… * i; j8 k+ j5 q! LThere's more… 7 }+ c' @9 w# U$ R5. Data Conversion . ^, S3 p: Q* ?4 \Introduction+ h( c5 O) |5 Y9 N8 V
Setting up the ADC8 Y2 l9 u1 S6 O1 d
How to do it…" E, {. U* p1 Y2 ^% F6 D
How it works…6 S7 m5 N8 q; N( s7 F1 F# D$ f
There's more…) M. A& R5 d, v" U! b; x
Configuring general-purpose timers( v& K+ W0 P+ }. e% U
How to do it… ; u+ j' Q6 M1 }" ^# OHow it works…( \/ Y$ f8 {. m! k7 p5 w9 A: D
Using timers to trigger conversions $ x/ T! j" b3 p$ VHow to do it…. a! H% [ X1 `& T6 l
How it works…5 C0 B- o5 R% H) E1 Z
There's more… 7 A* m5 z( g' i: C( O7 r) v& qSetting up the DAC + w; L8 f' _9 J# wHow to do it… ' s/ I6 i: `' F2 G0 c- MHow it works… 5 I8 i; V R2 V5 s% ~7 ^There's more…7 B/ Q# ]9 M: k F! d
Generating a sine wave * Y! j8 l/ F) X |3 XGetting ready ' I* z6 q& e5 Q( aHow to do it…/ D5 d/ q5 t* G; j; @2 k2 |! {
How it works… # Q( r1 `) G0 u/ \6. Multimedia Support7 {+ h, n: {* U2 x% y3 N3 c
Introduction 8 J' m1 U$ N" |2 JSetting the RTE for the I2C Peripheral Bus - _- S9 g) Q! E# Z- D- {; tHow to do it…; C0 x: ]0 R/ p# ]9 [- b
How it works… 0 H$ }0 R$ U3 j# AHow to use the LCD touchscreen- R3 D$ L" B; {$ Z! @5 b- p* J
How to do it…+ q- e# N, S6 u4 m+ F
How it works…' D1 W: o' Z+ L$ m5 D0 _" t: c& |
Writing a driver for the audio codec # _" d' V$ r- @ JHow to do it… G9 T @4 G1 O6 V4 _
How it works…- X" T/ q0 `6 [& }$ S. {& B+ c: Q
How to use the audio codec 7 i1 `1 K+ O; _, c! eHow to do it… I' x! \0 S& p' s4 _
How it works…2 k4 x( z7 ?& o) m. p+ D% Y- ]
How to use the camera , D* L* p8 Q) Q& g: V0 HHow to do it… 5 h5 C3 N" ^3 H$ X' l5 H- `How it works… + P. t# o: g. F' ]) J! {There's more…+ ?, s, A0 P: s* |3 O
Designing bitmapped graphics % h6 U5 a' e8 ^4 q/ H/ ~How to do it…" H# Z6 q5 L; l: J2 n/ Y$ d) k
How it works… ! Y! v, b# U: o, l" K: o6 lThere's more…, m9 g7 k2 {- q+ L. y
Ideas for games using sound and graphics # i7 E1 u _: J0 i. l7. Real-Time Signal Processing1 U9 C5 y4 q1 R$ T4 N4 s
Introduction% o' f2 b1 N* B: R' }' R" A3 d
Configuring the audio codec" l D+ r/ s7 m3 o4 ]) G
How to do it…6 J# Z& y9 V. q6 d8 g" T% A
How it works… 9 i7 [& ^5 s8 _2 j: S' K' }There's more…5 b# H8 s* J# d! P+ x. R w1 z$ c
How to play prerecorded audio3 t8 B- a) j6 E6 k
Getting ready% q( h5 O. o" d7 o" a- K* o, h
How to do it… " u0 }; [" D9 X# \How it works… 0 i6 ~8 x0 X/ @. Z$ y' uDesigning a low-pass digital filter$ E0 M6 G2 E4 l
Getting ready & r6 Q( M$ } K, I9 {% P8 hHow to do it… # h% \4 _! ]9 l! ]How it works…! T, i/ ~( S I) e+ f3 a
How to make an audio tone control 6 b) {! d5 x0 \, T5 A6 h* Z4 u7 {Getting ready+ w8 U m r9 C2 p" ^1 K& S
How to do it… / {: N. g D# t; B; q/ FHow it works…1 ~2 O2 ^( [8 Q2 j' ]6 @
There's more... ; [ C* `. A8 i8. Real-Time Embedded Systems- R% Y' \: d+ G; ~; y6 U, X
Introduction ) P. {9 u! O; H/ rMultithreaded programs using event flags7 o& g& y4 N5 l1 c# l* d
How to do it… / K$ j9 S3 M0 r. |- ^How it works… ; {6 h# W. J B* z- w! f" E* }" d9 sMultithreaded programs using mailboxes$ A; z) ?: d7 b' Z" a* G+ d
How to do it… ! ~+ w) ^4 ^' y# B* S0 |. tHow it works…) X2 u) G0 o( X5 K" b
Why ensuring mutual exclusion is important when accessing shared3 F2 t/ z% |2 o! Q) F8 l
resources+ Y P4 c! A; y7 F
How to do it… # V0 L4 N& V3 ]: lHow it works… % v: h3 @+ v0 b! S' H. S2 z0 uThere's more…5 D; ^: G+ n: ~; h) ~; C
Why we must use a mutex to access the GLCD- T" z* N1 ~* @+ W6 B, s; Q2 T
How to do it… % L& S& P, X+ }! X$ ^How it works…2 D. G! W5 K& D7 d
How to write a multithreaded Pong game& N4 a7 d1 a* m6 V
How to do it… 8 E. o4 F& }& J( HHow it works… * J5 P( r! O3 c" Y% ~1 vDebugging programs that use CMSIS-RTOS , D- Z: u. U( ~" W$ K5 aHow to do it… 2 a' N1 H( J# t+ r+ ZHow it works…4 _: y- E. v: J: C. W" O
9. Embedded Toolchain 2 a9 x. z) L$ V: g1 GIntroduction 4 Q* y7 r5 N1 y, O& d: n. BInstalling GNU ARM Eclipse; j3 q$ r9 Q0 k( f
How to do it…# {% n9 `5 n5 [% g
How it works…; O$ M- S8 }( J% v- b( N! t
Programming the MCBSTM32F400 evaluation board# }2 R' a4 Z/ N! t* I0 D) q0 ]
How to do it… 2 k4 l9 p7 v# i1 ^- Y M2 OHow it works… / o7 ~* m, d& |5 R, c& m$ B) s& ^6 |How to use the STM32CubeMX Framework (API)" T& S# R9 {! q! f+ Y' ^
How to do it…7 G) f8 ]3 q0 y9 n' O
How it works…8 w2 n0 M4 i+ R, v
There's more…! E7 Y- k# c- n' z7 o# b' P6 u) W# I
How to port uVision projects to GNU ARM Eclipse 7 k; \8 a5 |0 \7 x0 z" oHow to do it… 0 V4 {1 ~: _: o( BIndex* t$ g3 j# X/ d4 l0 K- ]